Skip to content

Commit fcdf1d9

Browse files
feat: Implement close for PyvistaQT
1 parent cd4df1b commit fcdf1d9

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,7 @@ def plot(self, plottable_object: Any, name_filter: str = None, **plotting_option
600600
else:
601601
self.pv_interface.plot(plottable_object, name_filter, **plotting_options)
602602

603+
def close(self):
604+
"""Close the plotter for PyVistaQT."""
605+
if self._use_qt:
606+
self.pv_interface.scene.close()

src/ansys/tools/visualization_interface/backends/pyvista/pyvista_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import pyvistaqt
3030

3131
import ansys.tools.visualization_interface as viz_interface
32-
from ansys.tools.visualization_interface import DOCUMENTATION_BUILD
3332
from ansys.tools.visualization_interface.types.edge_plot import EdgePlot
3433
from ansys.tools.visualization_interface.types.mesh_object_plot import MeshObjectPlot
3534
from ansys.tools.visualization_interface.utils.clip_plane import ClipPlane
@@ -110,7 +109,8 @@ def __init__(
110109

111110
# Show the XY plane
112111
self._show_plane = show_plane
113-
if (not DOCUMENTATION_BUILD) or (DOCUMENTATION_BUILD and not use_qt):
112+
# if (not DOCUMENTATION_BUILD) or (DOCUMENTATION_BUILD and not use_qt) or (TESTING_MODE and not use_qt):
113+
if not use_qt:
114114
self.scene.add_axes(interactive=False)
115115

116116
# objects to actors mapping

src/ansys/tools/visualization_interface/plotter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ def show(
8181
screenshot=screenshot,
8282
name_filter=name_filter,
8383
**plotting_options
84-
)
84+
)

tests/test_generic_plotter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def test_plotter_pyvistaqt():
5151
pl = Plotter(backend=qt_backend)
5252
sphere = pv.Sphere()
5353
pl.plot(sphere)
54-
pl.show()
54+
# PyVista QT show() breaks PyTest, so we avoid it.
55+
qt_backend.close()
5556

5657

5758
def test_plotter_add_mb():

0 commit comments

Comments
 (0)