#!/usr/bin/env python import gtk, libglade # We put all of our gtk signal handlers into a class. This lets us bind # all of them at once, because their names are in the class dict. class GladeHandlers: def on_quit_clicked(event): gtk.mainquit() def on_button4_clicked(event): widgets['label1'].set_text("spam, spam, spam") print gtk.screen_width(), gtk.screen_height() class WidgetsWrapper: def __init__(self): self.widgets = libglade.GladeXML ('pyglade2.glade', "window1") self.widgets.signal_autoconnect(GladeHandlers.__dict__) # Gives us the ability to do: widgets['widget_name'].action() def __getitem__(self, key): return self.widgets.get_widget(key) widgets = WidgetsWrapper() gtk.mainloop ()