[Tutor] how to retrieve values from scale widget(sample code is attached)????

Charles Gruschow gruschow2@hotmail.com
Fri, 16 Mar 2001 22:18:14 -0600


how to retrieve values from scale widget(sample code is attached)????

I can figure out frames and the basic widget formats themselves, but I can't 
figure out how to retrieve data from this widget so I can use it as input 
data in some other part of a program.

Can you help???

(BTW, I think I am getting my clock program figured out (I think), that I 
was asking about earlier)

gruschow2@hotmail.com
Charles Gruschow

********************SAMPLE CODE BELOW****************

#!/usr/local/bin/python

from Tkinter import *
import sys
import string

def die(event):
    sys.exit(0)

def reader(s):
    global label

    f = string.atoi(s)
    f = f - 32
    c = f/9.
    c = c * 5.

    flabel["text"] = "Degrees Fahrenheit:  %s" % (s)
    label["text"] = "Degrees Celsius:  %d" % (int(c))

root = Tk()

button = Button(root,width=25)
button["text"] = "Quit"
button.bind("<Button>",die)
button.pack()

flabel = Label(root,text="Degrees Fahrenheit:")
flabel.pack(anchor=W)

frame=Frame(root)

scale2 = Scale(frame, orient=VERTICAL,from_=-40,to=212,width=10,
               length=100,sliderlength=20,troughcolor="cyan",command=reader)
scale2.pack(side=LEFT)

frame.pack(anchor=W)

label = Label(root,text="Degrees Celsius:")
label.pack(anchor=W)

root.title("Fahrenheit to Celsius")

root.mainloop()




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com