Debugging gobject signals
September 5, 2007
Here’s a little snippet I oftenly use to debug GObject signals:
import gobject def test_signals(obj): """Helper function to test signals It connects all `obj` signals to a dummy function which simply prints out all given arguments. Args: obj: A ``gobject.GObject`` """ if not isinstance(obj, gobject.GObject): print "test_signals failed: obj must be a GObject" return def foo(*args): print "Signal %r emitted by %r:" % (args[-2], args[-1].__class__.__name__), args[:-2] for signame in gobject.signal_list_names(obj): obj.connect(signame, foo, signame, obj)
In fact, it does nothing special, but I found it very useful during development.
from somewhere import test_signals test_signals(mywidget)