Update Label when Scale value changes

Jørgen Cederberg jorgen.cederberg at gmail.com
Tue Apr 19 09:46:45 EDT 2005


codecraig wrote:

> Hi,
>   I am using Tkinter and I have a Label and a Scale.  I want to update
> my label everytime the Scale value changes.  What is the best way of
> doing this?  Do i have to bind for every event type?  Or is there some
> better way?  If I do have to bind each type of event to the scale, what
> types occur for a Scale?
> 
> Thanks.
> 

Hi

you could use a variable. Below is simple program that connects the value of the scale to 
the label.


from Tkinter import *

root = Tk()

var = IntVar()
Label(root, textvariable=var).pack()
Scale(root, from_=-2.0, to=10.0, variable=var).pack()

root.mainloop()

Hope this helps
Jorgen Cederberg



More information about the Python-list mailing list