example Tkinter code?

richard_chamberlain richard_chamberlain at ntlworld.com
Fri Jul 21 02:38:28 EDT 2000


Hi,

Have a look at John Grayson's manning site (www.manning.com/grayson) you can
download the source from his book including code that demonstrates each
widget.

I really would recommend a copy as it's an excellent book.

from Tkinter import *
root=Tk()
myString=StringVar()
Label(root,textvariable=myString).pack()
myString.set("Well, eh, how about a little red Leicester.")
def changeLabel():
    myString.set("I'm, a-fraid we're fresh out of red Leicester, sir. ")
Button(root,text='Click Me',command=changeLabel).pack()
root.mainloop()

I presume where you're going wrong is you are not creating an instance of
StringVar and setting (or getting) the variable through that.

Richard
Locke <brown.2053 at osu.NOSPAM.edu> wrote in message
news:8l7cvb$c61$1 at mcnet.marietta.edu...
> does anyone know where i can find some example python/tkinter code? i am
> trying to learn, but i think some examples of how to use all those widgets
> would be useful.
>
> also, how can i change the text on a label? when i use the
> variabletext=whatever thing, the label wont show up.
>
> Thanks!
>
>





More information about the Python-list mailing list