0

I want to use a Tkinter scale to set the magnitude of an input. Therefore I want the ticks of the scale to be 1, 10, 100, 1000 etc.

My initial thoughts are that I will have the scale

magnitudescale = Scale(window1, from_ = 0, to = 3)

When the scale is moved there would be some function that takes the scale position and alters the value by 10^x

Is there a clean way to do this?

mayna
  • 3
  • 1
  • 2
  • 5
  • As far as I can tell, the Scale widget has no options for customizing its behavior to that extent. You'd have to create a Scale with a small integer range, with ticks and value hidden; use the `command=` option to update a separate Label with the derived value of `10**scale.get()`. The Scale has a `.coords()` method to calculate the slider position corresponding to a value; you could use this to accurately place tick Labels next to the Scale. – jasonharper Jan 20 '21 at 16:45
  • @jasonharper Do you know if there is a way to change the value that the scale displays? I edited my original question with an idea that I had but I suppose that it would only work if you could alter the value the scale displays. – mayna Jan 20 '21 at 16:51

1 Answers1

0

magnitudescale = Scale(window1, from_ = 0, to = 3)

I found that there are some clever ways to do this but none that do exactly what the question asks. The way that I ended up implementing this is to have the scale position command a function that takes the position of the scale and calculates 10^(X) this code looks like this

10**(magnitudescale.get())

Using this calculation we can change the text in a label placed above the scale so that the slider position corresponds with the values "1, 10, 100, 1000, etc."

mayna
  • 3
  • 1
  • 2
  • 5