aneuryzm
aneuryzm

Reputation: 64834

TKinter: a slider widget?

Is there a slider widget in TKinter libraries ?

I need a slider to set a specific value

Upvotes: 4

Views: 3971

Answers (2)

user1497423
user1497423

Reputation: 727

Yes there is a tkinter slider:

from tkinter import *
root = Tk()
scale = Scale(root, from_=0, to=100)
scale.pack()
root.mainloop()

Upvotes: 1

unutbu
unutbu

Reputation: 879481

See the effbot docs:

from Tkinter import *

master = Tk()
def vscale_cb(value):
    print('vertical: {v}'.format(v=value))
def hscale_cb(value):
    print('horizontal: {v}'.format(v=value))

w = Scale(master, from_=0, to=100, command=vscale_cb)
w.pack()

w = Scale(master, from_=0, to=200, orient=HORIZONTAL, command=hscale_cb)
w.pack()

mainloop()

Upvotes: 2

Related Questions