On Wed, Jul 30, 2003 at 07:32:26PM +0200, Dusausoy Bruno wrote:
> Le mer 30/07/2003 � 19:27, Dusausoy Bruno a �crit :
> > Hi, 
> > 
> > I'm quite new to pygtk and I have a problem. I've connected the
> > "clicked" signal to a button and it should normally call
> > exit_window.destroy() function. But Python gives me this error:
> > 
> > TypeError: destroy() takes no arguments (1 given)
> > 
> > with this code :
> 
> Really sorry, i pressed the wrong button :)
> 
> Here's the code :
> 
>         button = gtk.Button("Cancel", gtk.STOCK_CANCEL)
>         button.connect("clicked", exit_window.destroy)
>         exit_window.action_area.pack_start(button, gtk.FALSE, gtk.FALSE,
> 0)
>         button.show()

[snip] 
 
> Is there another way ? I mean, something more clean ?

A callback for a signal needs to have a certain signature. This means
that the callback for "clicked" specifies a certain number of arguments,
and that number of arguments may not be (and is not) the same as the
number of arguments for GtkWindow.destroy(). 

In this case, the only approach is to use a proxy function as a callback
and have that function call destroy(). That's not necessarily a bad
thing, though; you'll realize sooner or later that destroy() alone
wasn't what you wanted to call, and that you need to do that "one extra
thing" when closing that window.

The lambda solution is a simplified way of providing that proxy, but I
swear by defining explicit callback functions, even if all they do is
call a gtk method.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to