UPCOMING COURSES

Introduction to Python Programming

January 9 to 11, 2007

Cititel (Mid-Valley), Kuala Lumpur

Click here for more details and registration

Notify me of upcoming training courses

Tutorials

GUI Programming

Creating GUIs using Glade and PyGTK - Part 1

P.C. Boey, Pytech Resources

November 7, 2006

If you want to do GUI programming with Python, you have quite a number of development options to choose from. The most commonly used GUI toolkit is Tkinter (included in the Python distribution) while others such wxPython, PyQt and PyGTK also have their following.

This is the first part of a series of tutorials planned to introduce the basics of Python GUI programming using Glade, the libglade library and PyGTK.

Glade is an increasingly popular cross-platform RAD tool for quick and easy building of graphical user interfaces for the GTK+ toolkit. The interface is saved in XML format and this file is loaded by libglade which creates the user interface at runtime. This approach has a lot of flexibility as it allows one to choose from a variety of programming languages such as Python, C, C++, Java, Perl, PHP and several others.

Here's a brief description about PyGTK from the PyGTK website:

PyGTK provides a convenient wrapper for the GTK library for use in Python programs, and takes care of many of the boring details such as managing memory and type casting.

Many of the ideas for these tutorials are borrowed from the excellent PyGTK tutorial by John Finlay. I wanted to idea was to adapt them so that you could use them with Glade. I used Glade 3, Python 2.4 on Ubuntu Dapper; some of the windows may appear different on Glade 2. So, onwards with the first tutorial, creating a GUI Hello Glade World program.

The First GUI Program - Hello Glade World

Start up the Glade Interface Designer and you should see 3 windows titled Palette, Properties and 'Untitled 1 - Glade'. The Palette window contains icons for toplevels, containers and various widgets.

Click the window icon in the toplevels section of the palette. In the Properties window type in 'Hello Glade World' in the Windows Title property. A new window appears like the following:

Resources for Python GUI Programming

We use Python ourselves extensively and have a deep knowledge and understanding of the language. We offer:

Comments from particpants

“Very detailed introduction .....” - Zurina Rashid, Test Engineer, Smart Modular Technologies Sdn. Bhd.

“Hands on and practical training” - R. Shashikanth,Sr. Staff Engineer, Smart Modular Technologies Sdn. Bhd.