Back to: Python Programming
The Tkinter Scale widget is a graphical slider that allows a user to select a numerical value within a specified range. It provides an interactive way to input integer or float values, often used for controls like volume or brightness.
Key Concepts:
- Function: The
Scalewidget presents a slider knob that users can drag along a trough to adjust a value. - Orientation: It can be arranged either horizontally or vertically using the
orientoption. - Range: The minimum and maximum values are defined by the
from_(note the trailing underscore becausefromis a Python keyword) andtooptions. - Value Retrieval: The current value of the slider can be retrieved at any time using the
.get()method. - Callbacks: A Python function can be specified with the
commandoption, which will be called every time the slider is moved. - Control Variables: The value can be linked to a Tkinter variable (e.g.,
IntVarorDoubleVar) using thevariableoption, automatically reflecting changes in the widget and the program.
Common Options
| Option | Description |
|---|---|
orient | Sets the orientation to tk.HORIZONTAL or tk.VERTICAL. |
from_ | The starting value of the range (uses an underscore). |
to | The ending value of the range. |
command | A function to call when the slider is moved. |
tickinterval | Displays numerical tick marks along the scale at specified intervals (e.g., tickinterval=10). |
resolution | Sets the smallest increment by which the value can change (e.g., resolution=0.5 for half steps). |
length | The length of the scale (width for horizontal, height for vertical). |
label | Text label to display within the widget. |
Lets create a scale to show the temperature.
from tkinter import *
window = Tk()
scale = Scale(window, from_=0, to=100) # we can specify the scale start and end values
scale.pack()
window.mainloop()
This code outputs a very basic looking scale:

Now lets flip the scale so the 0 is at the bottom, then we’ll add a submit button so we can get the current value.
from tkinter import *
def submit():
print("The temperature is: "+ str(scale.get())+ " degrees C")
window = Tk()
scale = Scale(window,from_=100, to=0)
scale.pack()
button = Button(window,text="Submit",command=submit)
button.pack()
window.mainloop()
If we want to store the current temperature displayed on the slider when the button submit is “pressed”
from tkinter import *
def submit():
temp = scale.get()
print(f"The temperature is: {temp} degrees C") # Could also use str(temp)
window = Tk()
scale = Scale(window,from_=100, to=0)
scale.pack()
button = Button(window,text="Submit",command=submit)
button.pack()
window.mainloop()
We can make our scale horizontal:
from tkinter import *
def show_value():
# Get the current value from the scale and print it
print(f"Current value: {scale.get()}")
window = Tk()
# Create a horizontal scale from 0 to 100
scale = Scale(window, from_=0, to=100, orient=HORIZONTAL)
scale.pack()
# Create a button to show the value
button = Button(window, text='Show Value', command=show_value)
button.pack()
# Initialize the slider to a specific value (optional)
scale.set(20)
window.mainloop()

We can make size changes to our scale to make more useable:
from tkinter import *
def submit():
temp = scale.get()
print(f"The temperature is: {str(temp)} degrees C")
window = Tk()
scale = Scale(window,
from_=100,
to=0,
length=600,
orient=VERTICAL, # can also us HORIZONTAL
font=("Consolas",20),
tickinterval = 10, # adds numeric indicators for value
showvalue = 1, # 0 - hides current value, 1- default shows value
resolution = 5 # increment of slider
)
scale.set(((scale['from']-scale['to'])/2)+scale["to"]) # centre start position of slider
scale.pack()
button = Button(window,text="Submit",command=submit)
button.pack()

We can make cosmetic changes to our scale to make it look significantly nicer by injecting some colour into the picture:
from tkinter import *
def submit():
temp = scale.get()
print(f"The temperature is: {str(temp)} degrees C")
window = Tk()
scale = Scale(window,
from_=100,
to=0,
length=600,
orient=HORIZONTAL, # can also us VERTICAL (the default)
font=("Consolas",20),
tickinterval = 10, # adds numeric indicators for value
showvalue = 1, # 0 - hides current value, 1- default shows value
resolution = 5, # increment of slider
troughcolor = '#69EAFF', # makes the slider trough and icy blue colour
fg='#FF1C00', # sets the text (foreground) colour
bg='#111111' # sets the background colour
)
scale.set(((scale['from']-scale['to'])/2)+scale["to"]) # centre start position of slider
scale.pack()
button = Button(window,text="Submit",command=submit)
button.pack()
window.mainloop()
Here’s a final output of our scale turned horizontal:
