Tkinter command parameters

Lenny lennybonilla at hotmail.com
Sun May 19 19:36:45 EDT 2002


When I try to pass an argument to a button's function, it executes the
function
upon loading rather than when the button is pressed.  When the button
is pressed nothing happens.

the code is something like this:

self.mybutton = Button(parent, command = func(1))
self.mybutton.grid()

def func(number):
	print str(number)

What am I doing wrong?



More information about the Python-list mailing list