How can I set the default value of my tkinter Scale widget slider to 100?
Asked Answered
S

3

15

How can I set the default value of my slider to 100 ?

self.slider = tk.Scale(self.leftFrame, from_=0, to=256, orient=tk.HORIZONTAL, command=updateValue)
Shank answered 18/10, 2010 at 20:57 Comment(0)
D
22

cursor=100?

If that doesn't work, you can always manually self.slider.set(100).

Diplostemonous answered 18/10, 2010 at 21:1 Comment(1)
This answer is probably outdated. See official API: tkdocs.com/pyref/ttk_scale.htmlCasanova
S
6

1. Set

Use the set method 1 2 : self.scale.set(100)

2. Variable

Use the variable option 3 4 to assign a Variable 5 6 7

self.scale_var = DoubleVar()
self.scale_var.set(1)
self.scale = tk.Scale(self.leftFrame, from_=0, to=256, orient=tk.HORIZONTAL,
    command=updateValue, variable=self.scale_var)
Spoilfive answered 12/4, 2020 at 18:9 Comment(0)
C
0
self.slider= tk.Scale(self.leftFrame, from_=0, to=256,orient=tk.HORIZONTAL,
command=updateValue)
self.slider.set(1)//or what ever value you want
self.slider.pack()

first give a name to scale then use set with value and at last pack()

Customhouse answered 11/4, 2022 at 12:57 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Had

© 2022 - 2024 — McMap. All rights reserved.