Hi, I'm having trouble with a tk scale widget. So far no one at the python forum
has an answer so I found this site.

As long as the resolution is set to 1, the start value can be anything I want but
as soon as I set the resolution any higher it changes the start value. Ex: I have

from_=3 

for a start parameter. Here's what I get for different resolutions r:

r start
2 4
3 3
4 4
5 5
6 6
7 0
8 0
9 0
10 0

And if I want my start to be 19:
r start
2 20
3 18
4 20
5 20
6 18
7 21
8 16
9 18
10 20

This doesn't do me any good if I want resolution = 10 for: 3, 13, 23, 33,
43, etc. or 19, 29, 39, 49, etc.

Why does this happen? Is it fixable?

205 Views
from_=3

You would have to dive into the source to see why but the docs give me a clue it's rounding to Integers and again, you get to the source to see why this happens. I had someone counter that it shouldn't round but it does unless...

The default resolution is 1, which causes the widget to round all values to the nearest integer value. You can use the resolution option to specify another resolution; use -1 to disable rounding.

So if you don't want to get into source, and you want your start to be say 19 with a resolution of 2, what happens when you try a start of 18? Does it start at 19 with a resolution of 2?

I should have written how I worked around such long ago. This was over a decade ago so psuedocode.

Say we have a textbox with a value and a slider. Let the slider start be default and the step be one as usual. Set the max to be what works for the following.

Textbox value = StartValue + (SliderValue * step)

This was done because something similar was not working as we wanted in the native slider but with one line of code, done.

If I use 18 as the start and resolution = 2 then it does start at 18 but when I try 18 and 10 it starts at 20 and goes up by 10. For some reason it doesn't like odd numbers as seen in my other message.
As for your bit of code where does it go? Inside the scale object with the other parameters?

The one line of code goes where you pick up and use the slider value since the slider does not work as you wish so you fix it with ... one line of code.

Yes I keep trying that but it doesn't work. Mind you I've only been learning Python for a few days so I have a lot to learn still. I'll post my code and the error message once I figure out how to put them in the forum code box.