uBoscuBo
uBoscuBo

Reputation: 91

Centering Scale Command value on Tkinter

I am trying to move the numeric value 0.0 to the center of the Scale command from tkinter package. I tried to anchor and justify it, but I get the following error:unknown option "-anchor" or unknown option "-justify". Please see the image for a visual example.

Edit: I am trying to keep the 0.0 value in the center of the scale.

enter image description here

I took the liberty to simplify the code.

from tkinter import *

root = Tk()
root.geometry('800x600')

exampleScale = Scale(root, resolution=0.1, from_=0, to=1, orient=HORIZONTAL,
                     width=250, length=550)
exampleScale.config(font=('Times', 32))
exampleScale.grid(row=1,column=1)

root.mainloop()

Thank you in advance!

Upvotes: 1

Views: 81

Answers (1)

Barbaros Özhan
Barbaros Özhan

Reputation: 65363

One tecnique uses setting of sliderlength parameter of Scale to double times of font size value :

from tkinter import *

root = Tk()
root.geometry('800x600')

fsize=32
exampleScale = Scale(root, sliderlength=fsize*2, resolution=0.1, from_=0, to=1,
                     orient=HORIZONTAL, width=250, length=550)
exampleScale.config(font=('Times', fsize))
exampleScale.grid(row=1,column=1)


root.mainloop()

Upvotes: 1

Related Questions