I invite you to take a look to the source code of my simplest application http://www.giuspen.com/nautilus-pyextensions/ where as you can see gtk.Builder() is called only once and there's no need for further calls.
the code that you have to look for: class GladeWidgetsWrapper: """Handles the retrieval of glade widgets""" def __init__(self, glade_file_path, gui_instance): try: self.glade_widgets = gtk.Builder() self.glade_widgets.set_translation_domain(cons.APP_NAME) self.glade_widgets.add_from_file(glade_file_path) self.glade_widgets.connect_signals(gui_instance) except: print "Failed to load the glade file" def __getitem__(self, key): """Gives us the ability to do: wrapper['widget_name'].action()""" return self.glade_widgets.get_object(key) def __getattr__(self, attr): """Gives us the ability to do: wrapper.widget_name.action()""" new_widget = self.glade_widgets.get_object(attr) if new_widget is None: raise AttributeError, 'Widget %r not found' % attr setattr(self, attr, new_widget) return new_widget ..... class NautilusPyExtensions: """The application's main window""" def __init__(self, store): ... # instantiate the Glade Widgets Wrapper self.glade = GladeWidgetsWrapper(cons.GLADE_PATH + 'nautilus-pyextensions.glade', self) ..... furthermode in the code you access the widgets with "self.glade.widgetname", all signals are connected. Hope this helps. Giuseppe. On Mon, Jun 27, 2011 at 17:02, Mac Ryan <quasipe...@gmail.com> wrote: > I posted the same question on Stack Overflow, but so far it only got 3 > views and no answers... :( > > http://stackoverflow.com/questions/6492000 > > In the design of my program I would like to pass around the > gkt.Builder() instance to various modules (each of them has > some of the handlers for managing the GUI), but I found out > that once the builder is instantiated one can only call the > connect_signals() method once: if called more than once, any > call after the second will return None (which would mean: > all signals have been connected, which is a blatant lie!). > > I tried to see if I could understand how/where gtk.Builder > stores the handler names that are assigned within the Glade > GUI, in order to write my own method to overcome this limitation, > but after more than an hour of console experiments I still > haven't understand where this information is stored. > > Is there anybody on the list that is able to advice me? Basically I > would be happy in any of these scenarios: > > * Find a way to re-use the same builder over and over. > * Find an alternative method to *AUTO-assign* methods of various modules > as callbacks to GUI-emitted signals (with the GUI being defined in a > monolithic Glade Builder XML file). > * Find a way to extract from the from the gtk.Builder (or in some other > way) the pairs widget-instance<->expected-handler-name as defined in > the Glade editor. > > As for my previous mail on this list: I solved the problem myself: > what I misunderstood was the correct use of the method dialogue.run(). > > Thanks in advance for your time, > /mac > _______________________________________________ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ >
_______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/