[pygtk] Glade XML wrapper and easy callbacks

Doug Quale quale1 at charter.net
Thu Aug 5 21:56:22 WST 2004


Graham Ashton <gashton at cmedltd.com> wrote:

>     def connect_signals(self, obj):
>         for name in obj.__class__.__dict__.keys():
>             if hasattr(obj, name):
>                 candidate_callback = getattr(obj, name)
>                 if callable(candidate_callback):
>                     self._xml.signal_connect(name, candidate_callback)

If I understand the pygtk FAQ correctly, in sufficiently recent
versions of pygtk you can simply use

     self._xml.signal_autoconnect(self)

Like Sridhar I also find it inconvenient to have to specify signal
names in the glade file and then match them up in my code.  I think
it's much easier to forget about setting the signals in the glade file
and simply connect them based on method names.  The only requirements
this puts on you is that you should set sensible names for the
important widgets in the glade file and you must use a standard
pattern for the signal handling method names.  I think both
requirements are good practice so I don't find them to be a burden.


More information about the pygtk mailing list