autoconnecting signals with libglade & PyGTK?



I have been learning Python over the past few weeks, so I am by no means an
expert.  My hope is to write a series of articles for linux.com, one of
which I would like to demonstrate RAD in Gnome using PyGTK.

With libglade (in C) there is a function to autoconnect signals.  There
doesn't seem to be any explicit function to do this with PyGTK, but, near as
I can tell, this functionality is supposed to happen automatically.

By combing through build.py, I see __setup_sighandlers is called upon
initializtion of a new widget.  For each signal added using glade, it does:

   signame = sig.name
   self.__signals[sig.handler] = (sig.get('object', node.name), (), None)
   if sig.get_bool('after', FALSE):
      widget.connect_after(signame, self.__signal_handler, sig.handler)
   else:
      widget.connect(signame, self.__signal_handler, sig.handler)

So it connects the signal to an internal function called __signal_handler.
Notice that it adds to some signals dictionary a tuple whose third element
is None.  Now if we jump over to __signal_handler, we see:

   def __signal_handler(self, wid, *args):
      signame = args[-1]
      args = args[:-1]
      objname, data, handler = self.__signals[signame]
      if not handler: return
		[ ... stuff deleted ... ]

It returns if handler isn't defined, and handler is the third element in the
tuple.  This is harcoded to None in __setup_sighandlers.  So, all this code
seems to be written to autoconnect signals, which is what I want to do, but
I can't see how it could work.  Any help would be appreciated.

Cheers,
Jason.

--
Unix/Network Administrator
Algoma University College
Sault Ste. Marie, Ontario
--
Assistant Project Manager: http://dev.linux.com
Columnist: http://secure.linux.com
Personal homepage: http://orion.dok.org



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]