K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
916 stars 123 forks source link

removing a plot does not update the kpanel #445

Open jmrouet opened 5 months ago

jmrouet commented 5 months ago

k3d python and js version is the same: yes 2.16.0

Description

when removing a plot element with the "plot -= xxx" syntax, the plot object still appears in the K3D Panel

What I Did

in a first cell

plot = k3d.plot()
line = k3d.line([0,0,0,1,0,0], name="test", group="toto")
plot += line
plot.display()

here the line is displayed as expected and toto/test appears in the "objects" section of the panel

then in another cell :

plot -= line

actually removes the line plot, but is is still displayed in the panel on the side.

And if unchecking/checking the "visible" toggle button, the line reappears, so actually the reference to the object still exists somewhere.... is there a leak ?

image

if I later progammatically hide and show the menu with

plot.menu_visibility = False
plot.menu_visibility = True

then the menu gets updated, but it is not very convenient

artur-trzesiok commented 1 week ago

@jmrouet good spot. Very likely my silly error in js code. I will fix it.