== Automatically Connecting Slots by Name == The code in attachment to replace connectSlotsByName() has been working great for me. I'm replacing more and more QObject.connect() -like code with it (I could not use the connectSlotsByName() from Qt because it binds callbacks twice (and yes, even if I did decorate my callbacks) and most importantly because my callbacks are not on the same object. --MartinBlais {{{ #!python def connectSlotsByName(container, callobj): """ A version of connectSlotsByName() that uses a potentially different object to search for widget instances and to search for callbacks. This is more flexible than the version that is provided with Qt because it allows you to bind to callbacks on any object, not just on the widget container class itself. You can also call this with a number of combinations of container and callback objects. * 'container': an instance whose attributes will be inspected to find Qt widgets. * 'callobj': an object which will be inspect for appropriately named methods to be used as callbacks for widgets on 'container'. See QtCore.QMetaObject.connectSlotsByName() for some background info. """ logging.debug('connectSlotsByName container=%s callobj=%s' % (container, callobj)) for name in dir(callobj): cb = getattr(callobj, name) if not callable(cb): continue mo = re.match('on_(.+)_([^_]+)$', name) if not mo: continue nwidget, nsignal = mo.groups() try: widget = getattr(container, nwidget) except AttributeError: logging.debug(" Widget '%s' not found; method '%s' will not be bound." % (nwidget, name)) continue # Support the QtCore.pyqtSignature decorator. signature = '%s(%s)' % (nsignal, getattr(cb, '_signature', '')) logging.debug(' Connecting: %s to %s: %s' % (widget, signature, cb)) QObject.connect(widget, SIGNAL(signature), cb) }}}