Vizard 7 » Command Index » Vizard modules » viztask » <viztask>.waitEvent
7.6

<viztask>.waitEvent

Wait for a specified event to occur

<viztask>.waitEvent(  
event  
all = False  
)  
event
The event to wait for
all = False
If True, the data object will receive a list of all the events that occured while the Condition object was waiting for an event.

If False, the data object will receive a single tuple representing the last event that occured while the Condition object was waiting for an event.

Remarks

This command will create a Condition object that will wait for the specified event to occur.

The yielded command returns a viz.Data object with the following information about the condition:

Properties

data

A tuple containing the event data, if all is False.

A list of tuples containing the data for all the events that occured, if all is True.

Return Value

viztask.Condition object

Example

Example 1:
import viztask

myslider = viz.addSlider( pos = (0.5,0.5,0) )

def MyTask():

    while True:

        d = yield viztask.waitEvent(viz.SLIDER_EVENT)

        if d.data[0] is myslider:
            print(d.data[1])

viztask.schedule( MyTask() )

Example 2:
import viztask

CUSTOM_EVENT = viz.getEventID("super special event")

def MyTask():

    while True:

        d = yield viztask.waitEvent(CUSTOM_EVENT,all=True)

        print('Event data:')
        for e in d.data:
            print(e[0])

viztask.schedule( MyTask() )

vizact.onkeydown(' ',viz.sendEvent,CUSTOM_EVENT,4)
vizact.onkeydown(' ',viz.sendEvent,CUSTOM_EVENT,5)
vizact.onkeydown(' ',viz.sendEvent,CUSTOM_EVENT,6)