WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Define tick positions for viz.SLIDER (https://forum.worldviz.com/showthread.php?t=4104)

hotshotiguana 01-10-2012 01:14 PM

Define tick positions for viz.SLIDER
 
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:
Code:

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.


All times are GMT -7. The time now is 05:13 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC