Hi fellow PyGTK users.
I recently checked in a patch to fix bug 102650,
It changes the behavior of glade.XML.signal_autoconnect slightly;
First of all you can now pass in any kind of Mapping objects, eg all
objects that support __getitem__, dictionary like items. But that's not
all.
You can also pass in a normal instance, and if it doesn't have an item
like the signal handler, it will fallback to using the _attribute_ of
the current object.
What does this mean for you?
Let me show you with the following example:
class MyProgram:
def __init__(self):
wtree = glade.XML('MyProgram.glade')
wtree.signal_autoconnect(self)
def on_button_show_clicked(self, button): ...
def on_button_edit_clicked(self, button): ...
def on_button_copy_clicked(self, button): ...
def on_button_move_clicked(self, button): ...
So instead of doing:
wtree.signal_autoconnect(
{'on_button_show_clicked': self.on_button_show_clicked,
'on_button_edit_clicked': self.on_button_edit_clicked,
'on_button_copy_clicked': self.on_button_copy_clicked,
'on_button_move_clicked': self.on_button_move_clicked})
you just pass in an object, self, an instance in this case.
wtree.signal_autoconnect(self)
And glade connects everything for you.
I imagine that every glade user on the list can remove tons of lines
from their programs now :)
Unfortunately this is only for pygtk 1.99.x.
But hey, if you're still using 0.6.x it's time to upgrade soon anyway.
--
Johan Dahlin <[EMAIL PROTECTED]>
Async Open Source
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/