2006-04-25

Python and LibGlade

I've found that Python and LibGlade are also wonderfully paired these days. This Python code

import gtk
import gtk.glade

class appGui:
def __init__(self):
callbacks = {
"on_button1_clicked" : self.on_button1_clicked,
"on_window1_delete_event" : gtk.main_quit
}
self.do_bindings(callbacks)
return

def do_bindings(self, callbacks):
self.xml = gtk.glade.XML("simple.glade")
self.xml.signal_autoconnect( callbacks )
return

def on_button1_clicked(self, widget):
entry = self.xml.get_widget("entry1")
print entry.get_text()
return

appGui()
gtk.main()

uses the same simple.glade file that the Overholt demo created. Try it!

No comments:

Post a Comment