Tkinter problem

Eirik hannibalkannibal at yahoo.no
Sun Jun 22 10:02:39 EDT 2003


"Chad Netzer" <cnetzer at sonic.net> skrev i melding
news:mailman.1056276938.31254.python-list at python.org...
>
> > 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>
>
>

What does the "if __name__=='__main__':" mean? I do not fully understand
this example.






More information about the Python-list mailing list