#1
|
|||
|
|||
exiting a yield statement
Hello there,
I have a question regarding exiting a yield statement, after a certain time elapsed. I am changing a global variable according to a keypress (using yield viztask.waitKeyDown) within a function, if that keypress should not happen, I want to exit the yield statement after a certain time interval. And continue the protocol with the unchanged global variable. I might be wrong using yield, and there is some other way (I read about python threading?Running a timer parallel to yield?), could you point me to some example code? I couldn't find this scenario in the tutorial. Thank you. Code:
Step=1 Motion = 15 def control(): global Motion ..... #dosomething with Motion for i in range(1,x) d = viz.Data() yield viztask.waitKeyDown(['y','n'],d) #or, if no key was pressed, after 2 sec exit yield if d.key == 'y': Motion = Motion - Step elif d.key == 'n': Motion = Motion + Step |
#2
|
|||
|
|||
Have a look at the viztask.waitAny condition. I believe the example on that page does exactly what you want.
|
#3
|
|||
|
|||
Thank you! that I must have overlooked!
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Vizard Tip of the Month: Use Tasks to Simplify your Code | Gladsomebeast | Vizard | 5 | 05-02-2008 05:30 PM |
switch statement | vrlab | Vizard | 1 | 08-04-2004 11:23 AM |