tags:

views:

30

answers:

1

Is there a slider widget in TKinter libraries ?

I need a slider to set a specific value

+1  A: 

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()
unutbu
@unutbu Thanks, one more thing. I'm able to change the values range, but how can I resize the slider ?
Patrick
And one more thing: is there a way to place more widget on a row instead of one below the other one ? thanks
Patrick
@Patrick: The layout of the GUI can be controlled by specifying arguments to the `pack` commands. See http://effbot.org/tkinterbook/pack.htm. "Resizing" is not done by specifying pixel dimensions, but rather by how you pack widgets together. This allows for dynamic resizing when the window is resized. Packing will also allow you to place more than one widget in a row.
unutbu