I have a tk slider in my python program and I am trying to get its value every time I move it. Program does read out the initial value of the slider, but that is all that gets read out. Here is my code:
valuelist[50, 100, 150, 200]
class MainApp(Frame):
def valuecheck(val, self, scale):
scalepic = scale
print scalepic.get()
def createControls(self):
scalepic = Scale(self, from_=min(valuelist), to=max(valuelist), resolution = 25, orient=HORIZONTAL)
scalepic.set(100)
scalepic.configure(command = self.valuecheck(val, scalepic))
scalepic.pack()
def __init__(self, parent):
Frame.__init__(self, parent, width = 800, height = 600)
self.pack()
self.createControls()
I tried adding this to the body of valuecheck:
newval = min(valueList, key=lambda x:abs(x-float(val)))
scalepic.set(newval)
print newval
and got rid of resolution option when defining scalepic. I also tried passing scalepic.get() as an argument for val. I also tried removing val as an argument in valuecheck What else should I try?