pyvista.RenderWindowInteractor.add_observer#

RenderWindowInteractor.add_observer(event, call, interactor_style_fallback=True)[source]#

Add an observer for the given event.

Parameters:
eventstr | int

The event to observe. Either the name of this event (string) or a VTK event identifier (int).

callcallable()

Callback to be called when the event is invoked.

interactor_style_fallbackbool

If True, the observer will be added to the interactor style in cases known to be problematic.

Returns:
int

The identifier of the added observer.

Examples

Add a custom observer.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> obs_enter = pl.iren.add_observer(
...     "EnterEvent", lambda *_: print('Enter!')
... )
../../../_images/pyvista-RenderWindowInteractor-add_observer-1_00_00.png