WidgetHelper.add_slider_widget(callback, rng, value=None, title=None, pointa=(0.4, 0.9), pointb=(0.9, 0.9), color=None, pass_widget=False, event_type='end', style=None, title_height=0.03, title_opacity=1.0, title_color=None, fmt=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.


The method called every time the slider is updated. This should take a single parameter: the float value of the slider.


Length two tuple of the minimum and maximum ranges of the slider.

valuefloat, optional

The starting value of the slider.

titlestr, optional

The string label of the slider widget.

pointatuple(float), optional

The relative coordinates of the left point of the slider on the display port.

pointbtuple(float), optional

The relative coordinates of the right point of the slider on the display port.

colorstr or sequence, 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.

event_typestr, optional

Either 'start', 'end' or 'always', this defines how often the slider interacts with the callback.

stylestr, optional

The name of the slider style. The list of available styles are in pyvista.global_theme.slider_styles. Defaults to None.

title_heightfloat, optional

Relative height of the title as compared to the length of the slider.

title_opacityfloat, optional

Opacity of title. Defaults to 1.0.

title_colorstr or sequence, optional

Either a string, RGB sequence, or hex color string. Defaults to the value given in color.

fmtstr, optional

String formatter used to format numerical data. Defaults to None.


Slider widget.


>>> 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,
... )