Il cursore seleziona la lunghezza della freccia
Web VPython 3.2
#-------------------------------------------------------- parametri
step1 = 1
step2 = 2
MIN = step1-0.5
MAX = step2+1.0
#-------------------------------------------------------- binding
def bind_slider(evt):
x = evt.value
freccia.length = x
testo.text = x
#-------------------------------------------------------- scena
sfera1 = sphere(color = color.yellow, radius = 0.1,
pos = vector(step1, 0, 0))
sfera2 = sphere(color = color.yellow, radius = 0.1,
pos = vector(step2, 0, 0))
freccia = arrow (shaftwidth = 0.1)
#-------------------------------------------------------- i/o
scene.append_to_caption("\nLunghezza: ")
cursore = slider(bind = bind_slider, max = MAX, min = MIN,
step = 0.1, value = freccia.length)
scene.append_to_caption(" ")
testo = wtext (text = cursore.value)