Plotter.add_timer_event#
- Plotter.add_timer_event(max_steps, duration, callback)[source]#
Add a function to callback as timer event.
- Parameters:
- max_steps
int Maximum number of steps for integrating a timer.
- duration
int Time (in milliseconds) before the timer emits a TimerEvent and
callbackis called.- callback
callable() A callable that takes one argument. It will be passed step, which is the number of times the timer event has occurred.
- max_steps
See also
Examples#
Download Python source code | Download Jupyter notebook
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)