App.on

App.on(interval=None, timeout=None, frames=None, record=False, record_path='temp/out.gif', record_fps=None, playback_interval=None)[source]

Decorator for callbacks of a dynamic drawing process.

Parameters
intervalint, optional

Interval between subsequent calls to this function, in milliseconds.

timeoutint, optional

Timeout between subsequent calls to this function, in milliseconds.

framesint, optional

The number of frames of the process. If no frame number is provided, the process continues until the viewer is closed.

recordbool, optional

If True, record a screenshot of every frame.

record_pathstr, optional

The path where the recording should be saved.

playback_intervalint, optional

Interval between frames in the recording, in milliseconds.

Returns
callable

Notes

The difference between interval and timeout is that the former indicates the time between subsequent calls to the callback, without taking into account the duration of the execution of the call, whereas the latter indicates a pause after the completed execution of the previous call, before starting the next one.

Examples

angle = math.radians(5)

@viewer.on(interval=1000)
def rotate(frame):
    obj.rotation = [0, 0, frame * angle]
    obj.update()