WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
Old 01-04-2010, 01:43 PM
starbug starbug is offline
Join Date: Dec 2009
Posts: 5
return variable from keypress function

I am relatively new to Vizard and Python, could you point me to some solutions for the following problem?

I want to change a variable in function MyTask() according to a keypress - input in function onKeydown() (if-switch). I just haven't found a way to return a variable from onKeydown. I tried the viz.callback function, and to give it enough time, I am trying to combine it with the viztask.waitKeyDown() function, but I just cannot produce an output form onKeydown.

Here the respective code:

def onKeydown(key):
if key == 'y':
incr = 5
elif key == 'n':
incr = -5
return incr

def MyTask():

while True:
yield viztask.waitKeyDown(('y','n'))
a = 10
b = onKeydown(viz.callback(viz.KEYDOWN_EVENT, onKeydown))
a = a + b
print a

viztask.schedule( MyTask() )

Any suggestions? thanks a lot!
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
window.pick function over sub-window omidbrb Vizard 4 10-02-2009 05:23 AM
Documentating function names aaThomas Vizard 5 05-15-2007 10:50 AM
Do you know how to send a value for 'pool' to the onActionEnd function? ghazanfar Vizard 1 03-22-2007 11:25 AM
timers and director function Jerry Vizard 1 06-22-2006 10:47 AM function tavaksai Vizard 3 08-13-2004 12:05 PM

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

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