PDA

View Full Version : Define tick positions for viz.SLIDER


hotshotiguana
01-10-2012, 01:14 PM
Is there a way to define precise tick positions for a viz.SLIDER GUI element? For example, I want to only let someone move the slider to defined points along a linear space - numpy.linspace(0, 1, 26) - so I can easily get the index for the where the tick is located.

Any assistance is greatly appreciated.

Chris

farshizzo
01-10-2012, 02:17 PM
Within the slider callback you can compute the nearest defined point and move the tick to it. Example:import viz
import vizact
viz.go()

slider = viz.addSlider(pos=(0.5,0.1,0))

SLIDER_STEPS = 10

def UpdateSlider(pos):
val = round(SLIDER_STEPS*pos) / float(SLIDER_STEPS)
slider.set(val)
vizact.onslider(slider,UpdateSlider)

hotshotiguana
01-11-2012, 08:01 AM
Thanks. That works as advertised.