Slider

class vanilla.Slider(posSize, minValue=0, maxValue=100, value=50, tickMarkCount=None, stopOnTickMarks=False, continuous=True, callback=None, sizeStyle='regular')

A standard slider control. Sliders can be vertical or horizontal and they can show tick marks or not show tick marks.:

from vanilla import *

class SliderDemo(object):

     def __init__(self):
         self.w = Window((200, 43))
         self.w.slider = Slider((10, 10, -10, 23),
                            tickMarkCount=10,
                            callback=self.sliderCallback)
         self.w.open()

     def sliderCallback(self, sender):
         print "slider edit!", sender.get()

SliderDemo()

posSize Tuple of form (left, top, width, height) representing the position and size of the slider. The size of the slider sould match the appropriate value for the given sizeStyle.

Standard Dimensions
without ticks
Regular W 15 H 15
Small W 12 H 11
Mini W 10 H 10
with ticks
Regular W 24 H 23
Small W 17 H 17
Mini W 16 H 16

minValue The minimum value allowed by the slider.

maxValue The maximum value allowed by the slider.

value The initial value of the slider.

tickMarkCount The number of tick marcks to be displayed on the slider. If None is given, no tick marks will be displayed.

stopOnTickMarks Boolean representing if the slider knob should only stop on the tick marks.

continuous Boolean representing if the assigned callback should be called during slider editing. If False is given, the callback will be called after the editing has finished.

callback The method to be called when the slider has been edited.

sizeStyle A string representing the desired size style of the slider. The options are:

“regular”
“small”
“mini”
enable(onOff)

Enable or disable the object. onOff should be a boolean.

get()

Get the value of the slider.

getNSSlider()

Return the NSSlider that this object wraps.

getPosSize()

The position and size of the object as a tuple of form (left, top, width, height).

getTitle()

Get the control title.

isVisible()

Return a bool indicting if the object is visible or not.

move(x, y)

Move the object by x units and y units.

resize(width, height)

Change the size of the object to width and height.

set(value)

Set the value of the slider.

setMaxValue(value)

Set the maximum value allowed by the slider.

setMinValue(value)

Set the minimum value allowed by the slider.

setPosSize(posSize)

Set the postion and size of the object.

posSize A tuple of form (left, top, width, height).

setTickMarkCount(value)

Set the number of tick marks on the slider.

setTickMarkPosition(value)

Set the position of the tick marks on the slider.

For vertical sliders, the options are:

“left”
“right”

For horizontal sliders, the options are:

“top”
“bottom”
setTitle(title)

Set the control title.

title A string representing the title.

show(onOff)

Show or hide the object.

onOff A boolean value representing if the object should be shown or not.