TKinter:一个滑块小部件?

时间:2010-10-13 11:09:48

标签: python tkinter

TKinter库中是否有滑块小部件?

我需要一个滑块来设置特定值

2 个答案:

答案 0 :(得分:1)

请参阅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()

答案 1 :(得分:1)

是的,有一个tkinter滑块:

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