Reputation: 3
from Tkinter import *
master = Tk()
master.geometry("300x100")
master.title("Convert Scale To Farenheight")
def convertToFarenheight(f):
f=int(f)
f=f*9/5+32 ## convert toFarenheight
var = StringVar()
Label(master, textvariable=var).pack()
y=Scale(master,from_=-100,to=100,variable=var,orient=HORIZONTAL,command=convertToFarenheight)
y.pack()
mainloop()
My issue is i'm trying to change the text label to calculated value by my method run on the scale method. I'm not sure what to change in my method to get it to work. Any suggestions? Thanks
Upvotes: 0
Views: 64
Reputation: 2689
There was some serious problem in your indentation.
I think this is what you are trying:
from Tkinter import *
master = Tk()
master.geometry("300x100")
master.title("Convert Scale To Farenheight")
def convertToFarenheight(var):
f1= int(var)
f2.set(f1*9/5+32)
f2=IntVar()
x=Label(master,textvariable=f2)
x.pack()
var = StringVar()
y=Scale(master,from_=-100,to=100,variable=var,orient=HORIZONTAL,command=convertToFarenheight)
y.pack()
mainloop()
Upvotes: 1