PDA

View Full Version : onkeydown list of values


Cheff
07-01-2008, 01:29 AM
Hi,

i'm quit a rookie in the world of Vizard and i have a problem with making a list of values by keyboard action.
I have a list of values (60, 69, 52, 9, 55, 58, 10, 18, 56) and I want vizard to run throug the list from the beginning to the end , each time you hit the spacebar I want the script to give the next value. Once the last value is reached, I want it to jump back to the beginning and repeat.
I've tried something like this:

def onkeydown (key):
if key == ' ':
print vizact.choice( [60, 69, 52, 9, 55, 58, 10, 18, 56], viz.LOOP )
viz.callback(viz.KEYDOWN_EVENT,onkeydown)

but it doesn't quite work.

Can anybody help me with this problem?

Thanx

farshizzo
07-01-2008, 10:03 AM
Try the following code, it should do what you ant:numberCycle = viz.cycle([60, 69, 52, 9, 55, 58, 10, 18, 56])
def PrintNumber():
print numberCycle.next()
vizact.onkeydown(' ',PrintNumber)

Cheff
07-02-2008, 02:00 AM
yes it works!

thank you