Using Glade to write GUI applications

A few useful links for people who want to learn on how to write GTK applications using Glade



The video for using Glade with Python is not very clear, so I'll explain a little bit the process below.

1. Build your GUI

2. Open a .py file, and import gtk and gtk.glade
#!/usr/bin/python
import gtk
import gtk.glade


3. define your handlers method
def hander_method(widget):
do_something_here
do_more


4. load the glade XML
xml = gtk.glade.XML("/path/to/glade/file")


5. connect handlers to its methods/functions
dict = { 'handler_name' : handler_method,
'handler_name2' : handler_method2
}

xml.signal_autoconnect(dict)


6. run gtk instance
gtk.main()


I also have written a similar script to the ruby glade template generator in Video 3. It'll generate a very basic Python template for use. ( I couldn't find where to download GladeGen )

pyglade-gentemplate.py
Post a Comment

Popular posts from this blog

Adding simple popup to Plone frontpage

Tee'ing Python subprocess.Popen output

HOWTO: Mirroring Yum repositories using Yum-Utils