pyvista.Plotter.add_slider_widget#
- Plotter.add_slider_widget(
- callback,
- rng,
- value=None,
- title=None,
- pointa=(0.4, 0.9),
- pointb=(0.9, 0.9),
- color=None,
- pass_widget: bool = False,
- interaction_event: pyvista.InteractionEventType = 'end',
- style=None,
- title_height=0.03,
- title_opacity=1.0,
- title_color=None,
- fmt=None,
- slider_width=None,
- tube_width=None,
Add a slider bar widget.
This is useless without a callback function. You can pass a callable function that takes a single argument, the value of this slider widget, and performs a task with that value.
- Parameters:
- callback
callable() Called every time the slider is updated. This should take a single parameter: the float value of the slider. If
pass_widget=True, callable should take two parameters: the float value of the slider and the widget itself.- rng
tuple(float) Length two tuple of the minimum and maximum ranges of the slider.
- value
float,optional The starting value of the slider.
- title
str,optional The string label of the slider widget.
- pointa
tuple(float),optional The relative coordinates of the left point of the slider on the display port.
- pointb
tuple(float),optional The relative coordinates of the right point of the slider on the display port.
- color
ColorLike,optional Either a string, RGB list, or hex color string. Defaults to
pyvista.global_theme.font.color.- pass_widgetbool,
optional If
True, the widget will be passed as the last argument of the callback.- interaction_event
InteractionEventType,optional The VTK interaction event to use for triggering the callback. Accepts either the strings
'start','end','always'or a vtkCommand.EventIds.Changed in version 0.38.0: Changed from
event_typetointeraction_eventand now accepts either strings or vtkCommand.EventIds.- style
str,optional The name of the slider style. The list of available styles are in
pyvista.global_theme.slider_styles. Defaults toNone.- title_height
float,optional Relative height of the title as compared to the length of the slider.
- title_opacity
float,optional Opacity of title. Defaults to 1.0.
- title_color
ColorLike,optional Either a string, RGB sequence, or hex color string. Defaults to the value given in
color.- fmt
str,optional String formatter used to format numerical data. Defaults to
None.- slider_width
float,optional Normalized width of the slider. Defaults to the theme’s slider width.
- tube_width
float,optional Normalized width of the tube. Defaults to the theme’s tube width.
- callback
- Returns:
- vtkSliderWidget
Slider widget.
See also
Examples
>>> import pyvista as pv >>> pl = pv.Plotter() >>> def create_mesh(value): ... res = int(value) ... sphere = pv.Sphere(phi_resolution=res, theta_resolution=res) ... pl.add_mesh(sphere, name='sphere', show_edges=True) >>> slider = pl.add_slider_widget( ... create_mesh, ... [5, 100], ... title='Resolution', ... title_opacity=0.5, ... title_color='red', ... fmt='%0.9f', ... title_height=0.08, ... ) >>> pl.show()