Wednesday, February 26, 2014

Python GUIs with PyGTK and Glade

PyGTK is a system for developing GUIs in Python.  PyGTK runs on Linux and on Windows.  Glade is a free graphical GUI builder for use with GTK.  Glade can run on Windows or Linux.  It is important to know that PyGTK does not yet run with Python 3.  I uninstalled my Python 3 and installed Python 2.7.5 because PyGTK will run with Python 2.7.  You must have a compatible Python when using PyGTK.  I got Python 2.7.5 from this website.  Then I downloaded the pygtk-all-in-one-2.24.0.win32-py2.7.msi installer from this website.  This package comes with Glade.

You can write GUI code by writing code in PyGTK in the same fashion you can write code to create GUIs with Tkinter, which now comes bundled with Python.  But once you get used to using a graphical GUI designer like Netbeans, you will want to use a tool like Glade.

There are tutorials available for PyGtk.  One example of a good tutorial that comes with sample code is the tarball  pygtk2tutorial.tgz that can be downloaded from the website http://www.moeraki.com/pygtktutorial/index.html  Look for the link named "Gzip'd Tarball of Tutorial (1.42 MB)".  Once you unzip it, go into the folder pygtk2tutorial and double-click on index.html to read the tutorial with your web browser.  The example code is in the folder pygtk2tutorial\examples.

This kind of support makes Python a great language, for beginners and professionals alike.

Robert