python - Ipywidgets : How to get the list of comm opened in a jupyter notebook? - Stack Overflow

时间: 2025-01-06 admin 业界

I created, in a Jupyter Notebook, a GUI where many ipywidgets are created, displayed or not, closed depending of user choices, file opened, ... But I am not sure that I do not let some comms (.html#comms) opened. For example, in this simple code :

my_list = [1,2,3]
my_HBox = wg.HBox()
my_HBox.children = ( [ wg.Checkbox(value=True, description=f'{i}') for i in my_list ] )
display(my_HBox)

If my_HBox is closed (my_HBox.close()). The comms for the three checkboxes still exist. Even if they are not displayed because my_HBox has been closed. Indeed, they could be displayed and used, for example, display(my_HBox.children[1]).

I read carefully .html. So, I understand what happens in the example above.

But in the GUI, I designed, I am not sure to close all the childrens of childrens of childrens ... Because of the GUI complexity, perhaps, I could have missed some of them.

So, I am looking for a function (a method or something else) to get the list of all comms opened in a Jupyter Notebook. That means the list of Widget (in Python Kernel) and WidgetModel (in front-end) associated via a comms

最新文章