[pygtk] Glade, event handlers, & gtk.Builder question

Alessandro Dentella sandro at e-den.it
Wed Feb 9 21:57:27 WST 2011


On Wed, Feb 09, 2011 at 08:32:23AM -0500, Adam Tauno Williams wrote:
> builder = gtk.Builder()
> builder.add_from_file(self.gladefile)
> self.window = builder.get_object("MainWindow")
> 
> This, according to my understanding creates an instance of the
> MainWindow widget as defined in the Glade file.
> 
> Now if I want to connect the events defined in the Glade file to
> handlers of the 'current' instance I perform -
> 
> builder.connect_signals(self)
> 
> But according to the log messages this tries to connect any event
> handler defined in the glade file to methods of this object.  Is there a
> way to only connect event handlers for the "MainWindow" widget?  Do I
> need to define each widget in a separate Glade file?

In the Builder documentations it says:

  The connect_signals() method uses Python's introspective features to look at
  the keys (if object is a mapping) or attributes (if object is an instance)
  and tries to match them with the signal handler names given in the interface
  description. The callbacks referenced by each matched key or attribute are
  connected to their matching signals.

So that you can pass a dict with only the keys corresponding to the handler
you need to connect.

sandro
*:-)


-- 
Sandro Dentella  *:-)
http://www.reteisi.org             Soluzioni libere per le scuole
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy


More information about the pygtk mailing list