Per the docs, connect_signals
takes as the argument a mapping or instance, and
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 for example when you pass "mainwindow"
, which is an instance of str
, the attributes are e.g. such method names as upper
, lower
, isalpha
, and the like -- nothing to do with anything at all that you might be remotely interested about. And why would you want the attributes of win
to handle signals, either? IOW, what do you expect connect_signals
to do?
A more typical example use can be found e.g. in this SO question and this tutorial, which offers among others the following Python example:
class TutorialTextEditor:
def on_window_destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
builder = gtk.Builder()
builder.add_from_file("tutorial.xml")
self.window = builder.get_object("window")
builder.connect_signals(self)
as you see, here connect_signals
is used in the typical way -- i.e., passing an object (self
) with an on_window_destroy
method that (by introspection) will be used as the handler for the signal raised on window destruction.