pyvista.Plotter.add_checkbox_button_widget#
- 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.
- Parameters:
- callback
callable()
The method called every time the button is clicked. This should take a single parameter: the bool value of the button.
- valuebool, default:
False
The default state of the button.
- positionsequence[
float
], default: (10.0, 10.0) The absolute coordinates of the bottom left point of the button.
- size
int
, default: 50 The size of the button in number of pixels.
- border_size
int
, default: 5 The size of the borders of the button in pixels.
- color_on
ColorLike
,optional
The color used when the button is checked. Default is
'blue'
.- color_off
ColorLike
,optional
The color used when the button is not checked. Default is
'grey'
.- background_color
ColorLike
,optional
The background color of the button. Default is
'white'
.
- callback
- Returns:
vtk.vtkButtonWidget
The VTK button widget configured as a checkbox button.
Examples
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) >>> p.show()
Download the interactive example at Checkbox Widget.