>>>>> "John" == John Hunter <[EMAIL PROTECTED]> writes:
John> The problem comes in if I construct this dialog twice, then
John> when the signal is emitted, the handlers for both the
John> original instance and the new instance are called.
John> Is there a way to disconnect the signals from the previous
John> instance?
After a day or working on this, the only thing I could come up with
was to do the autoconnect step myself, because I needed to have the
widget ids to do the disconnect. So I wrote a base class that
handles all widgets defined in glade file with a given prefix; the
relevant class methods are
class PrefixWrapper:
#match 'on_widgetName_signal'; widgetName cannot have an underscore
rgx = re.compile('on_([^_]+)_(\w+)')
def __init__(self, prefix):
self.prefix=prefix
self.autoconnect()
def autoconnect(self):
# a list of (widget, id) tuples
self.connectionIds = []
for name in dir(self):
if not callable(getattr(self, name)): continue
m = self.rgx.match(name)
if m is None: continue
widgetName, signal = m.group(1), m.group(2)
thisWidget = Shared.widgets.get_widget(self.prefix+widgetName)
if thisWidget is None:
print 'Could not find widget', self.prefix+widgetName
continue
id = thisWidget.connect(signal, getattr(self, name))
self.connectionIds.append( (thisWidget, id) )
def disconnect(self):
for w, id in self.connectionIds:
w.disconnect(id)
If gtk.glade.XML.signal_autoconnect returned a list of (widget,
connectionid) tuples, or there was some other way to access them, then
none of this would be necessary. Is there a standard way to do what I
did here?
Thanks,
John Hunter
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/