WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to delay time in Vizard (https://forum.worldviz.com/showthread.php?t=3677)

Zhi 04-02-2011 07:47 AM

How to delay time in Vizard
 
Hi all,

I want to define a function which will be called when the mouse is clicked. The function will block the viz.MainView for a second. Here is my code:

import viz
import time
def BlockMainView():
viz.visible(viz.OFF)
time.delay(1)
viz.visible(viz.ON)
vizact.onmousedown(viz.MOUSEBUTTON_LEFT, BlockMainView)

However, the delay function seems being executed before viz.visible(viz.OFF) and viz.visible(viz.ON), so that the viz.visible(viz.OFF) seems never being executed. How can I solve the problem?

Zhi

Zhi 04-02-2011 01:43 PM

I have found a way around:

def myTask():
while True:
btn = yield viztask.waitMouseDown(None) #Wait for mouse click
viz.visible(viz.OFF) #Turn off the screen

if btn.button == 1: #Left botton click
yield function_a()
elif btn.button == 4: #Right botton click
yield function_b()

yield viztask.waitTime(1)
viz.visible(viz.ON) #Turn on the screen

viztask.schedule(myTask)

Cheers!
Zhi


All times are GMT -7. The time now is 06:04 PM.

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