Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Python » Tkinter » slider

Python Tkinter slider Example


from tkinter import *
from PIL import ImageTk, Image

root = Tk()
root.title("Example of Slider in Python / Tkinter")
root.geometry("300x200")

vertical_scale = Scale(root, from_ = 0, to=200)
vertical_scale.pack()

horizontal_scale = Scale(root, from_=0, to=200, orient=HORIZONTAL)
horizontal_scale.pack()

label = Label(root, text=horizontal_scale.get()).pack()

def slide():
    label = Label(root, text="Horizontal : "+ str(horizontal_scale.get()) + ", Vertical :" + str(vertical_scale.get())).pack()

button = Button(root, text="Click Me!", command=slide).pack()

root.mainloop()
how to display Slider in Python Tkinter