Archive | July, 2011

Developing desktop apps with Python-Clutter

13 Jul

If you want to develop some practical applications for Linux platforms then you should know at least one gui toolkit for creating user interfaces.So here I’ll show you how to employ one such library which is known as PyClutter(python-clutter).It is used to create windowed applications.Also obviously Python programming language will be used.So let’s dive in.

Installing PyClutter:

If you are using Ubuntu then you can fire up “Ubuntu Software Center” and search for “python-clutter”.Otherwise you can grab the library from here .

Using PyClutter:

First of all we have to set up the base on which our whole interface will be built.For this we will create a basic blank window.Here is the code to do that.

import clutter

def basic():





Save the above code in a file(“…….” are used just to show indentation of code.So delete them,they will result in syntax error if not removed) and run it like any other python script.You’ll see a blank window on executing the script.Breakdown of the above code is as follows

first of all we create an empty stage on which we will draw various elements

next,we call “show_all()” on Stage’s instance which will make every element inside the window visible.Also it’ll make the window visible.

finally we call the “clutter.main()” so that we can see the output.

Now for building real apps we need to know more about this library.

Setting color:

There are two methods to do that



The above code will set the background color of the window to blue.

Method 2:



In the above code we first make the color using rgba technique.If you’ve any idea about html then you might be familiar with this method.Finally we set the color of the window.Any other element’s(like rectangles,texts etc.) color can be set similarly.

Setting size:


The window now will be 500×400.

Setting window title:

stage.set_title(“Basic window”)

Writing Text:


tex.set_text(“Hello There!”)



The above code is self explanatory.Note that the text element should be added to the main window we created.For this,use


When all of the above code will be put together,you’ll get the window like this

Resulting Window


I’ll write more about PyClutter and how to use it for complex apps.Just stay in touch with my site.