Tkinter problem
Chad Netzer
cnetzer at sonic.net
Sun Jun 22 06:14:48 EDT 2003
> How can I make it wait until I press the button before the message in the
> label comes?
By making a function that sets the text, and then passing that function
to the button 'command' option. NOTE - you pass the function to the
'command' option, you do NOT call the function and pass the results to
the 'command' option. ie:
import sys
from Tkinter import *
def my_test_callback():
global root
root.t.set("Test-Text")
if __name__ == '__main__':
root = Tk()
root.t = StringVar()
root.l1 = Label(root, textvariable = root.t)
root.b1 = Button(root, text = "Button", command = my_test_callback)
root.bE = Button(root, text = "End", command = sys.exit)
root.l1.grid()
root.b1.grid()
root.bE.grid()
root.mainloop()
If you haven't seen it already, I recommend:
http://home.att.net/~stephen_ferg/thinking_in_tkinter/
--
Chad Netzer <cnetzer at sonic dot net>
More information about the Python-list
mailing list