Tkinter Tutorial - Scale

  1. Tkinter Scale Example
  2. Tkinter Scale Orientation and Resolution

A Scale is the widget that user could select a numerical value from the range of values by moving a slider knob along the scale.

You could specify the minimum and maximum values and also the resolution of the scale. The scale provides a bounded numerical value compared to a Entry widget.

Tkinter Scale Example

Tkinter Scale_Basic.py
import tkinter as tk
 
app = tk.Tk() 
app.geometry('300x200')
app.title("Basic Scale")

scaleExample = tk.Scale(app, from_=0, to=10)
scaleExample.pack()
app.mainloop()
scaleExample = tk.Scale(app, from_=0, to=10)

from_ specifies the minimum value, and to specifies the maximum value of the range.

Tkinter Scale Orientation and Resolution

Tkinter Scale_Orientation and Resolution.py
import tkinter as tk
 
app = tk.Tk() 
app.geometry('300x200')
app.title("Tkitner Scale Example")

scaleExample = tk.Scale(app,
                        orient='horizontal',
                        resolution=0.1,
                        from_=0,
                        to=10)
scaleExample.pack()
app.mainloop()

Tkinter Scale Horizontal and Different Resolution

scaleExample = tk.Scale(app,
                        orient='horizontal',
                        resolution=0.1,
                        from_=0,
                        to=10)
orient='horizontal'

The default orientation of Tkinter scale is vertical as shown in the first example. You need to specify the orient attribute of scale to be horizontal to get a horizontal Tkinter scale.

resolution=0.1

The resolution of the scale could be modified by resolution option that has the default value of 1.

Contribute
DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.