Plotter.add_checkbox_button_widget(callback, value=False, position=(10.0, 10.0), size=50, border_size=5, color_on='blue', color_off='grey', background_color='white')#

Add a checkbox button widget to the scene.

This is useless without a callback function. You can pass a callable function that takes a single argument, the state of this button widget and performs a task with that value.


The method called every time the button is clicked. This should take a single parameter: the bool value of the button.

valuebool, optional

The default state of the button.

positiontuple(float), optional

The absolute coordinates of the bottom left point of the button.

sizeint, optional

The size of the button in number of pixels.

border_sizeint, optional

The size of the borders of the button in pixels.

color_oncolor_like, optional

The color used when the button is checked. Default is 'blue'.

color_offcolor_like, optional

The color used when the button is not checked. Default is 'grey'.

background_colorcolor_like, optional

The background color of the button. Default is 'white'.


The VTK button widget configured as a checkbox button.


The following example generates a static image of the widget.

>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> p = pv.Plotter()
>>> actor = p.add_mesh(mesh)
>>> def toggle_vis(flag):
...     actor.SetVisibility(flag)
>>> _ = p.add_checkbox_button_widget(toggle_vis, value=True)

Download the interactive example at Checkbox Widget.