GNU/Linux Desktop Survival Guide
by Graham Williams
Glade: GUI Builder
Glade is a graphical user interface (GUI) builder for creating your own applications using the GTK+ (GIMP ToolKit) and Gnome toolkits. It provides a visual tool (c.f. Visual Basic) to interactively
create the GUI on a canvas from components (widgets) provided by the toolkits. Interfaces can be rapidly developed and source code in a variety of languages can be automatically generated. Glade directly generates C source code with support for C++, Ada95, Python, Perl, and Eiffel available within Glade via external tools. Alternatively, and often preferably, can be used to dynamically create the user interface directly from the XML data at run time, leading to much simpler code.
As with many Gnome products Glade's native save format is an open standard XML (gzip compressed) allowing the interface to be modified, transformed, and viewed by many other XML tools (or even edited manually in your favourite text editor if desired). Independent applications exist that allow differently structured C source code to be generated directly from the XML data.
In this chapter we will illustrate the use of Glade and Libglade with the Python language, which is a simple to learn and easy to use programming language. We begin with an overview of using Python to generate GUIs directly in GTK+, and then using Glade. We then proceed through the development of a sample Glade application by way of a walk-through that will build the interface. This is followed by walk-throughs that will turn this interface into a fully functional application. These walk-throughs begin with a C implementation and include packaging the application for distribution using the GNU packaging tools (automake, autoconf, and tar). We then walk through the use of the library as an alternative for C. Versions of the application in Python and C++ are also presented. We complete this chapter with reference sections covering all aspects of Glade and some basics of the Gtk+ and Gnome toolkits.