plotter.clear() doesnt clear sphere_widgets
See original GitHub issueDescribe the bug, what’s wrong, and what you expected.
My application need to repeatedly create similar 3D scenes with new input data. I’m using Plotter.clear()
to clear the scene before building the new one. Plotter.clear()
does clears the view of the scene, but doesn’t clear the list of sphere_widgets.
After I clear the scene by using plotter.clear()
the list in plotter.sphere_widgets still contains all the previous sphere widgets I added and when I add the new sphere_widgets to the scene it returns the list with all the previous widgets plus the new one.
Steps to reproduce the bug.
import pyvista as pv
plotter = pv.Plotter(notebook=False)
def key_callback(*args, **kwargs):
print(f"number of sphere_widgets before clearing: {len(plotter.sphere_widgets)}")
plotter.clear()
print(f"number of sphere_widgets after clearing: {len(plotter.sphere_widgets)}")
plotter.add_checkbox_button_widget(key_callback, value=True)
def callback(*args, **kwargs):
pass
coords = [[1,1,1], [2,2,0], [0,3,3]]
stem_widgets_heights = plotter.add_sphere_widget(callback, center=coords, color='red', pass_widget=True, test_callback=False)
plotter.show()
System Information
--------------------------------------------------------------------------------
Date: Sat Oct 22 22:30:43 2022 +11
OS : Linux
CPU(s) : 8
Machine : x86_64
Architecture : 64bit
RAM : 5.7 GiB
Environment : Python
File system : ext4
GPU Vendor : AMD
GPU Renderer : AMD Radeon Vega 8 Graphics (raven, LLVM 13.0.1, DRM 3.42, 5.15.0-47-generic)
GPU Version : 4.6 (Core Profile) Mesa 22.0.1
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
pyvista : 0.36.1
vtk : 9.2.2
numpy : 1.21.5
imageio : 2.22.1
appdirs : 1.4.4
scooby : 0.5.12
matplotlib : 3.5.1
pyvistaqt : 0.9.0
PyQt5 : 5.15.6
IPython : 8.5.0
scipy : 1.8.0
jupyterlab : 3.4.8
--------------------------------------------------------------------------------
Screenshots
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Clearing a Mesh or the Entire Plot - PyVista
This example demonstrates how to remove elements from a scene. import pyvista as pv. plotter ... Sphere()) plotter.remove_actor(actor) plotter.show(). clear.
Read more >Matplotlib graphs do not clear in events with clear_output #1853
Hi, I noticed this in 7.0.5, however it used to work in 6.0.0 with just clear_output , before it's behaviour was changed.
Read more >clear output of output widget plotting a Seaborn figure does ...
I would like to display in the output widget a new figure every time, i.e. totally clear the content and then add stuff...
Read more >vedo.plotter API documentation
Axes() for the full list of options. azimuth/elevation/roll : float, optional move camera accordingly the specified value. viewup : str, list ...
Read more >NetLogo 6.3.0 User Manual
Clarify that clear-globals doesn't affect interface globals. ... The NetLogo interface editor now supports “Undo” for widget addition, deletion, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@banesullivan Thank you for the help. Calling sphere_widget.Off() before clearing the list solves my issue.
@banesullivan I can confirm the above resolves the issue: first turning the widget
Off()
before clearing the underlying list.This needs to be done for all the
clear()
methods becausepyvista
crashes with all widgetclear()
methods when the list is cleared before the widget is turned off.