PlotterComponent#
- class PlotterComponent(plotter: Any)[source]#
Structural protocol for plotter component classes.
A component class must accept the plotter instance as its single
__init__argument. Any public methods on the class become available asplotter.<namespace>.<method>(...)once the class is registered withregister_plotter_component().Two optional dunder hooks participate in the plotter lifecycle and are detected by
getattrat lifecycle time, not by the protocol (since they are optional):__plotter_close__(self) -> None— called when the plotter closes. Only fires on components that were actually constructed (i.e. accessed at least once). Use this to release VTK observers, close websockets, stop background threads, or otherwise undo any side effects the component is responsible for.__plotter_deep_clean__(self) -> None— called fromBasePlotter.deep_clean. Optional; if absent, deep clean falls through to the normal close path on the next plotter shutdown.
Added in version 0.48.0.
Examples
Declare a component that satisfies the protocol.
>>> from pyvista import PlotterComponent >>> class MyComponent: ... def __init__(self, plotter): ... self._plotter = plotter >>> isinstance(MyComponent(None), PlotterComponent) True