I am using pygtk. I am not getting what is the difference between connect() and connect_object() in pygtk. Can somebody clarify me on this ?
Thanks.
As explained here, connect_object is used to replace the object passed to the callback method by default (which is the one that emitted the signal).
For example,
>>> label = gtk.Label()
>>> button = gtk.Button()
>>> def callback(obj):
... print obj
>>> button.connect('clicked', callback) # button will be passed by default
>>> button.emit('clicked')
<gtk.Button object at 0x27cd870 (GtkButton at 0x22c6190)>
>>> button.disconnect_by_func(callback)
>>> button.connect_object('clicked', callback, label) # label will be passed instead of button
>>> button.emit('clicked')
<gtk.Label object at 0x27cd9b0 (GtkLabel at 0x22b64f0)>
Note: Usually in callback methods, you'll be interested in the object that emitted the signal (the one passed by default), so connect_object isn't used frequently.
In addition, you'll find here the following explanation:
connect_object()allows the PyGTK widget methods that only take a single argument (self) to be used as signal handlers.