[pygtk] gtkButton signal handling in glade

Maciej Katafiasz mnews22 at wp.pl
Thu Sep 23 20:03:47 WST 2004


Dnia 23-09-2004, czw o godzinie 03:07 -0300, Jose de Paula Eufrasio
Junior napisał:
> Hello again :\
> 
> I got some weird stuff today trying to make the on_button_clicked
> signal execute a callback function.
> 
> passing the function with arguments (like 
> 
> on_ButtonX_clicked: ButtonXClicked('Argh!')
> 
> made my function execute right in the startup (and print Argh to the
> console). After trying almost everything I called the function without
> arguments, and I got the "memory position" of the button, as
> <gtk.Button object (GtkButton) at 0x40a5a324>
> on the console window.

you should do that like:

def on_button_clicked(button):
	print "Button %s clicked" % button

my_button.connect("clicked", on_button_clicked)

Note there's no () after on_button_clicked in connect call, that's
because you pass _function_ to be invoked, not invoke it yourself.
Generally, read pygtk tutorial available on http://www.pygtk.org,
everything is clearly explained there

Cheers,
Maciej

-- 
"Tautologizm to coś tautologicznego"
   Maciej Katafiasz <mnews2 at wp.pl>
       http://mathrick.blog.pl



More information about the pygtk mailing list