GUI Programming with Python, Glade and
Python + Glade + smartglade = Productivity Gain2
A smart way to build GTK+ based applications using Python programming language, Glade GUI builder and smartglade module on almost all modern platforms. Inspired by libglade, it brings a fresh way how to deal with widget identifiers in programs. It smartly fixes their names and initialize. smartglade allows dynamic loading of user interfaces from XML descriptions (Glade files or buffers). smartglade automatically creates (gets children, assigns identifiers and initialize them) corresponding widgets from XML descriptions. smartglade uses following Python modules: pygtk, gtk, gobject and xml.
According to test1_gtk_glade.py example, it is obvious that we manually have to get all required widgets using get_widget() method. Problem appears if our XML description has too many widgets, and it makes very hard to manually get all of them. Using gtk.glade to 'get' all necessary widgets, this bit of code will linearly increase.
xml = gtk.glade.XML('test1.glade', 'window1')
self.window = self.window1 = xml.get_widget('window1')
self.entry1 = xml.get_widget('entry1')
self.button1 = xml.get_widget('button1')
Even if XML description has hundreds of widgets in same window, smartglade automatically does job for us. Following bit of code is everything that is required to 'get' all widgets from 'window1' widget.
self.window = self.window1
There are two very simple examples that use smartglade (test1.py with test1.glade and test2.py), and one that uses gtk.glade (test1_gtk_glade.py with test1.glade). test1.py uses external Glade file test1.glade, and it is required in same directory where is test1.py. test2.py uses internal Glade buffer as XML description of GUI. Both XML descriptions are generated with Glade GUI builder.
Examples with smartglade module can be found on this address http://code.google.com/p/smartglade/.
Just copy smartglade.py into working directory.