Box Widget

Box Widget#

The box widget can be enabled and disabled by the pyvista.Plotter.add_box_widget() and pyvista.Plotter.clear_box_widgets() methods respectively. When enabling the box widget, you must provide a custom callback function otherwise the box would appear and do nothing - the callback functions are what allow us to leverage the widget to perform a task like clipping/cropping.

Considering that using a box to clip/crop a mesh is one of the most common use cases, we have included a helper method that will allow you to add a mesh to a scene with a box widget that controls its extent, the pyvista.Plotter.add_mesh_clip_box() method.

import pyvista as pv
from pyvista import examples

mesh = examples.download_washington_bust()
box widget

After interacting with the scene, the clipped mesh is available as:

[UnstructuredGrid (0x791c9d4036a0)
  N Cells:    150000
  N Points:   75004
  X Bounds:   3.921e+02, 9.406e+02
  Y Bounds:   -1.498e+03, -9.939e+02
  Z Bounds:   3.181e+02, 1.014e+03
  N Arrays:   7]

Tags: widgets

Total running time of the script: (0 minutes 1.816 seconds)

Gallery generated by Sphinx-Gallery