I want to initialize the value of a Scale widget to 2. How can I do this? Because I used a grid, .set won't work properly.
Here is my code:
Scale(self, command=self.onMove, movesvariable=self.var, from_=1, to=10,orient=HORIZONTAL,length=500,tickinterval=0.5, resolution=0.1, cursor = 'hand2 ').grid(columnspan ='200',rowspan = '4',sticky= W)
Change this to two lines:
.grid()returnsNone; calling it after Scale like you've done won't return a Scale object like you would expect, it will return a Nonetype. Implementing this small change should allow you to use.seton whatever variable you store the Scale object in. (yourScalein this example)As an aside: You might want to remove the
settag in your question:setreferences a data structure, not the set function from Tkinter.