Bennhyon
Bennhyon

Reputation: 3

Tkinter: How to get the actual max/length of the scale widget?

I'm developping an application in python with tkinter and need to get the actual max value of a Slider/Scale widget. I'm kinda new so it may be obvious but i don't seem to find any answers anywhere, thanks :).

Edit: I need to get the max position the slider can be at, like if the slider goes from 0 to 68, i should be able to get 68 because it's the actual max it can go to.

Upvotes: 0

Views: 1174

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 386230

All widgets have a cget method which can return the value of a configurable attribute.

In your case it would be something like this:

the_scale = tk.Scale(...from_=0, to=68)
...
print("max value: ", the_scale.cget("to"))

Upvotes: 1

Adri
Adri

Reputation: 599

A Scale widget is declared this way:

w = Scale(root, from_=min, to=max)

with min and max the minimum and maximum value of the Scale widget.

You can use the get method to query the widget

w.get()

Upvotes: 0

Related Questions