#!/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() class WidgetsWrapper: def __init__(self): self.widgets = libglade.GladeXML ('pyglade1.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 ()