pyvista.Plotter.add_timer_event#

Plotter.add_timer_event(max_steps, duration, callback)[source]#

Add a function to callback as timer event.

Parameters:
max_stepsint

Maximum number of steps for integrating a timer.

durationint

Time (in milliseconds) before the timer emits a TimerEvent and callback is called.

callbackcallable()

A callable that takes one argument. It will be passed step, which is the number of times the timer event has occurred.

Examples

Add a timer to a Plotter to move a sphere across a scene.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(sphere)
>>> def callback(step):
...     actor.position = [step / 100.0, step / 100.0, 0]
...
>>> pl.add_timer_event(
...     max_steps=200, duration=500, callback=callback
... )
../../../_images/pyvista-Plotter-add_timer_event-1_00_00.png