maybe I have known the reason The function specified in the second argument is called a "callback function", and should generally be of the form:
def callback_func(widget, callback_data): where the first argument will be a pointer to the *widget* that emitted the signal, and the second (*callback_data*) a pointer to the data given as the last argument to the connect() method as shown above. If the callback function is an object method then it will have the general form: def callback_meth(self, widget, callback_data): where *self* is the object instance invoking the method. thanks 2009/12/9 engine spot <engines...@gmail.com> > Hi everyone > when I study pygtk, for the code > self.button1.connect("clicked", self.callback, "button 1") > when I check the PyGTK 2.0 Reference Manual,I find this: > > The "clicked" gtk.Button Signal > > def callback(*button*, *user_param1*, *...*) > > *button* : > the button that received the signal > > *user_param1* : > the first user parameter (if any) specified with the connect() method > > *...* : > additional user parameters (if any) > there are only two Parameters > > so I change the default callback function > > def callback(self,widget, data=None): > print "Hello again - %s was pressed" % data > > > to > > def callback(widget, data=None): > print "Hello again - %s was pressed" % data > > but I get this error > > TypeError: callback() takes at most 2 arguments (3 given) > > > can any one help me ? > > >
_______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/