Making GUI applications with Gazpacho

Earlier I have made some simple GUI applications using PyGTK and Glade, which is surprisingly easy. Now I have another small itch to scratch and have another go at some GUI app. Only this time I decided that the coolness of Gazpacho looked slightly nicer to me, so gave that a try.

Creating the UI is easy enough and after some messing around I had something that would do. Gazpacho claims to create glade files compatible with Libglade, so I just went about what I did last time:

import gtk
import gtk.glade


class MainWindow:
    def __init__(self):
        self.wtree = gtk.glade.XML('ddmp.glade')
        self.wtree.signal_autoconnect(self)

    def on_mainwindow_destroy(self, *args):
        gtk.main_quit()

    def main(self):
        gtk.main()


if __name__ == '__main__':
    app = MainWindow()
    app.main()

However this didn't quite work, I got libglade warnings about unexpected element <ui> and unkown attribute constructor. Furthermore gtk.glade gave tracebacks about assertions of GTK_IS_WIDGET. After a quick search on the great internet that didn't result in anything (I was wondering if my libglade was too old or so) I had a look at the examples supplied (stupid me, why would I not look there first?) and sure enough, they don't use gtk.glade. So the above code changes into:

import gtk
from gazpacho.loader.loader import ObjectBuilder


class MainWindow:
    def __init__(self):
        self.wtree = ObjectBuilder('ddmp.glade')
        self.wtree.signal_autoconnect(self)

    def on_mainwindow_destroy(self, *args):
        gtk.main_quit()

    def main(self):
        mainwindow = self.wtree.get_widget('mainwindow')
        mainwindow.show()
        gtk.main()


if __name__ == '__main__':
    app = MainWindow()
    app.main()

So Gazpacho needs a different loader for the XML, the returned object appears to be behaving as the gtk.glade.XML widget tree which is nice (since gazpacho documentation seems to be non-existing). I suppose libglade doesn't cope with the gtk.UIManager code created by gazpacho yet (the FAQ seems to suggest there are patches pending) and that their custom loader translates it to something libglade understands. This does make me wonder if you can use gazpacho when using any other language then python, the examples only contained python code. Surely they'll want to support any language that has libglade?

Lastly it seems to hide windows by default, which I actually quite like. I remember in glade you had to explicitly hide dialog windows or they would show up at startup, this seems slightly more logical.

Overall I do quite like gazpacho so far, I'm glad I chose it and would recommend it. It still has some rough edges but is very nice already.