Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Python Tk Scale

  • Scale
  • HORIZONTAL
  • VERTICAL
import tkinter as tk

def run_action():
    h = scale_h.get()
    print(h)

    v = scale_v.get()
    print(v)

app = tk.Tk()
app.title('Scale')

scale_h = tk.Scale(app, from_=0, to=42, orient=tk.HORIZONTAL)
scale_h.pack()

scale_v = tk.Scale(app, from_=1, to=100, orient=tk.VERTICAL)
scale_v.pack()
scale_v.set(23)

action_button = tk.Button(app, text='Action', width=25, command=run_action)
action_button.pack()

app.mainloop()