Coupled variables in Tkinter???
Maurice
bertvansesamstraat at hotmail.com
Thu Feb 20 03:56:14 EST 2003
Dear all,
I want implement a GUI in which I've four sliders using Tkinter.
To do this I've put all the stuff in a class:
class SliderAndAxesWidget:
def __init__(self,master):
self.Slider1Value=IntVar()
self.Slider2Value=IntVar()
self.Slider3Value=IntVar()
self.Slider4Value=IntVar()
self.Slider1Value=0
self.Slider2Value=0
self.Slider3Value=0
self.Slider4Value=0
self.sliderLabel=Label(frame,text="Positions")
self.xCFP=Scale(frame,to="255",orient="horizontal",variable=self.Slider1Value,command=self.say_test)
self.yCFP=Scale(frame,to="255",orient="horizontal",variable=self.Slider2Value,command=self.say_test)
self.xRcv=Scale(frame,to="255",orient="horizontal",variable=self.Slider3Value,command=self.say_test)
self.yRcv=Scale(frame,to="255",orient="horizontal",variable=self.Slider4Value,command=self.say_test)
self.xCFP.grid(column="0",row="1")
self.yCFP.grid(column="0",row="2")
self.xRcv.grid(column="0",row="3")
self.yRcv.grid(column="0",row="4")
self.q=Button(frame,text="GoodBye",command="exit")
self.u=Button(frame,text="Update Axes",command="self.UpdateAxes()")
self.q.grid()
self.u.grid(column="1",row="5",columnspan="2")
frame.grid()
def say_test(self,master):
print self.xCFP.get()
This class I use in a pyhton program as follows:
root=Tk()
app=SliderAndAxesWidget(root)
root.mainloop()
My problem is that when I used on of the four sliders, the other three
also change so they are coupled.
I didn't expect this because the have different variables.
How can I prevent this coupling??
Thanks in advance.
More information about the Python-list
mailing list