calling functions from Tk

scoobysnax5336 at my-deja.com scoobysnax5336 at my-deja.com
Sat Dec 25 10:05:43 EST 1999


I'm trying to understand this.  I've cleaned it up as much as I can to
illustrate my problem.  From my buttons, if I call a function with no
value, it works fine.  When I call it with a value, it executes at
runtime but not when the button is pressed.

from Tkinter import *

def test(stuff='test'):
	print stuff

root = Tk()

b=Button(root, text="Call test", width=8, command=test)
b.pack(side=LEFT)

b=Button(root, text="Call test('blah')", width=12, command=test('blah'))
b.pack(side=LEFT)

b=Button(root, text='Exit', width=6, command=root.quit)
b.pack(side=LEFT)

root.mainloop()



Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list