Notice: Undefined index: order_next_posts in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 194

Notice: Undefined index: post_link_target in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 195

Notice: Undefined index: posts_featured_size in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 196

Build a Twitter client using PyGTK

This tutorial shows how to use Python to build GUI applications very quickly. After an introduction to PyGTK you will learn how to build a simple, but elegant Twitter post client…

This article originally appeared in issue 85 of Linux User & Developer.
Linux User & Developer, one of the nation’s favourite Linux and Open Source publications, is now part of the award winning Imagine Publishing family. Readers can subscribe and save more than 30% and receive our money back guarantee – click here to find out more.

You will need the following packages to be installed in your system:
PyGTK: Install PyGTK development packages. If you are using Ubuntu, install the package python-gtk2-dev.
python-simplejson: simplejson is an extensible JSON (JavaScript Object Notation) encoder and decoder for Python.
Python Twitter: Python Twitter library provides a pure Python interface to the Twitter API. You can download it here. Once you have the source file (python-twitter-0.6.tar.gz), perform the following steps to install it…

$ tar xvfz python-twitter*
$ cd python-twitter*
$ sudo python install

If sudo is not working for you, try logging in as root, using su and then run the steps.

Source Code examples:
HelloWorld and TwitPost

Traditionally, GUI application development has been complex. On top of that, it could only be done with compiled programming languages like C or C++. Actually, that is not entirely true: you could have used Tcl/Tk scripting language to build GUI applications. But those interfaces looked like how KDE1 was: very ancient.

PyGTK is a set of wrappers around the GTK (GIMP Toolkit) library. It lets you to easily create programs with a graphical user interface using the Python programming language. PyGTK gives you best of both worlds: the simplicity of the Python programming language and the power of GTK. GTK allows you to develop fully fledged cross-platform GUI applications. It also facilitates rapid application development using glade libraries.

PyGTK is used in many places. As far as Linux is concerned, you will find PyGTK powering many Linux distributions’ set-up tools; prime examples are Fedora/Red Hat – in Anaconda (the Red Hat installer) and various GUI administration tools – and Mandriva Linux (Drakconf-based tools). This is owing to the fact that Python in its own right is a great tool for administration-related tasks. PyGTK is also the official GUI toolkit for the OLPC (One Laptop per Child) project. It is used heavily in building netbook/tablet-friendly applications.