Tkinter problem

Chad Netzer cnetzer at
Sun Jun 22 12:14:48 CEST 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

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)



If you haven't seen it already, I recommend:

Chad Netzer <cnetzer at sonic dot net>

More information about the Python-list mailing list