The One-Laptop-Per-Child’s XO laptop has Tepache to generate code from Glade XML.
http://wiki.laptop.org/go/PyGTK/Hello_World_with_Glade_and_Sweettepache
But they’ve added some extras to it to make it play nicely in the sugar desktop environment and perhaps updated versions of glade 3. I guess it works for them, but i’m not developing on or for the XO right now.
Tepache is a code sketcher for python that uses pygtk and glade.
It’s supposed to create pure python modules so they call it a sketcher rather than a generator. But the Tepache homepage is broken and it looks like it hasn’t been updated since July 2005 anyway. Following a link to anything useful will result in the incarnation of an ugly oops page.
An error has been encountered in accessing this page.
1. Server: kefir.sourceforge.net
2. URL path: /tepache/tepache
3. Error notes: NONE
4. Error type: 404
Gladex was broken out of the box. It wouldn’t load any plugins. The entries just show up in the dialog with place holders, so it won’t actually generate anything at all.
Autoglade doesn’t seem to be that old, but it’s not working on my apps and the documentation is, well… limited. There’s a README.txt but it’s empty. And a CHANGES.txt, but that’s empty too.
./autoglade.py id.glade
True: root=None
True: autoinit=None
True: autonitsplit=:
True: autodump=shell
True: AutoGlade::__init__(glade=id.glade, root=None, autorun=True, autodump=shell)
True: Should open id.glade
True: working directory: /home/user/python/trunk/autoglade
./autoglade.py:703: Warning: g_set_prgname() called multiple times
properties=properties)
['__getTopLevelWidgetNames']: start
['__getTopLevelWidgetNames']: finish
['__getTopLevelWidgets']: startvi
['__getTopLevelWidgets']: finish
__mapAutoInvokeWidgetNames: start
['__findStockItem']: __findStockItem(gtk-preferences, <type 'gtk.Button'>) start
['__findStockItem']: __findStockItem(gtk-delete, <type 'gtk.MenuItem'>) start
['__findStockItem']: __findStockItem(gtk-paste, <type 'gtk.ToolButton'>) start
['__findStockItem']: __findStockItem(gtk-copy, <type 'gtk.MenuItem'>) start
['__findStockItem']: __findStockItem(gtk-about, <type 'gtk.Button'>) start
['__findStockItem']: __findStockItem: parent = <DOM Element: object at 0x8ff244c>
['__getitem__']: __getitem__(AutoGlade, __repr__)
['__getitem__']: checking if key=__repr__ matches reSetTreeviewCell RE
Traceback (most recent call last):
File "./autoglade.py", line 2716, in <module>
autodump=options.autodump)
File "./autoglade.py", line 715, in __init__
self.__getStockItems()
File "./autoglade.py", line 1583, in __getStockItems
self.__autoStockItems[asi][ASI_GTKCLASS])
File "./autoglade.py", line 1565, in __getStockItem
self.__autoGladeObjects[agokey] = self.__findStockItem(stock, gtkClass)
File "./autoglade.py", line 1621, in __findStockItem
raise RuntimeError('Parent is not widget')
RuntimeError: Parent is not widget
Time to just carve it out by hand.
class MyGui:
def __init__(self):
self.builder = gtk.Builder()
self.builder.add_from_file("app-dialog1.glade")
...
Try: http://wiki.laptop.org/go/Tepache
I also found “Writing PyGTK applications in a visual way” {http://kefir.sourceforge.net/tepache/}
and “Glade to Python conversion” {http://python-forum.com/pythonforum/viewtopic.php?f=4&t=6687}
9:22 pm
I ended up saving the glade xml in guibuilder format and writing the code by hand. I know it’s not nearly as manly as writing all the gtk stuff from scratch, but I really like having the gui separated from the code like this.