On 25 Apr 2001 16:30:46 +0200, Eduardo Ferro wrote:
>
> Can i get the names of the handlers from a widget tree from a
> libglade? how?
> I want to use the autoconect without knowing the the names of the
> functions that i define at the glade file
>
Well, in one way or the other, you will have to know what they are, I do
not believe it is possible to avoid that, because at some point you need
to code the handlers for them.
However, you can simplify your signal connecting code by naming the
function that handles the code, the same as the signal. If you grep
through your glade file hor "handler" you will see a list of all the
handlers you need to code for. Then, you can create the a function of
the same name.
What I do is to put the application code into a class. Then, in the
class __ini__ method, I do the following:
self.mw.connect('delete_event',mainquit)
signals = self.signals = {}
for key in dir(self.__class__):
signals[key]=getattr(self,key)
self.widgets.signal_autoconnect(self.signals)
So a basic structure is like so:
class GUI:
def __init__(self):
self.mw.connect('delete_event',mainquit)
signals = self.signals = {}
for key in dir(self.__class__):
signals[key]=getattr(self,key)
self.widgets.signal_autoconnect(self.signals)
def on_exit_button_clicked(self,obj):
stuff to handle the event
This way, I don't need to build the list of signals and their handlers
by hand.
Hope that helps,
Bill
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk