any close notification for widgets and cells?

42 views
Skip to first unread message

nlecle...@gmail.com

unread,
Dec 20, 2016, 6:17:48 PM12/20/16
to Project Jupyter
Hi all,

I need to stop a thread running in the background when the associated interface (i.e. main ipywidget) is closed or when the associated cell is deleted. Not doing so would lead to a bunch of zombie threads after a while. So my questions are:

Is there a way to be notified when the user click on close button of a ipywiget? 
I tried the 'observe' way but it doesn't seem to work - the callback is not called when I close the widget.

As a workaround, hiding the 'X' button could also be a solution cause I can provide my own 'close' button. 
Is it possible to hide the default X button?

Concerning the cells, is there a way to be notified when a specific cell is removed from the notebook? 

Thanks for your help,
Nicolas

nlecle...@gmail.com

unread,
Dec 21, 2016, 12:38:12 PM12/21/16
to Project Jupyter
No answer so far :( Are my questions stupid?  
A simple yes or no for each of them would really help. 
Thanks.

Thomas Kluyver

unread,
Dec 21, 2016, 1:20:41 PM12/21/16
to Project Jupyter
On 21 December 2016 at 17:38, <nlecle...@gmail.com> wrote:
No answer so far :( Are my questions stupid?  

I don't think they're stupid, but please give us a few days before complaining that an email has gone unanswered; people are busy, and it may take some time for the relevant people to get to your question.

I don't think there's a notification when a widget view is closed, but I don't follow that part of the code closely, so hopefully someone else can provide a more authoritative answer.
Message has been deleted

nlecle...@gmail.com

unread,
Dec 21, 2016, 2:43:33 PM12/21/16
to Project Jupyter
Oops, complaining was not the idea. 
I simply thought that the answer were obvious for the average Jupiter user. I was wrong.
Sorry for that and many thanks for replying.

Sylvain Corlay

unread,
Dec 22, 2016, 7:45:48 AM12/22/16
to jup...@googlegroups.com
Hi Nicolas,

I think that this would be a good think to do to handle the case when a widget (model) is completely closed from the front-end. However, is it more subtle than it sounds.

Widgets implement a MVC pattern. The Widget object on the Python side is synchronized with a Javascript "Model". The kernel has no notion of view, or how many views exist for a given model. This design is a consequence of the agnosticity of the architecture to the front-end. The kernel should not know the nature of the (possibly multiple) clients that are connected to it.

In the notebook, the X button only closes a view from the document. Destroying a view does not mean that the widget model is destroyed and triggers no action in the backend.

Sylvain


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/15ad43d9-cca1-477d-b917-3a55721b2472%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

nlecle...@gmail.com

unread,
Dec 23, 2016, 5:52:13 AM12/23/16
to Project Jupyter
Sylvain,
I have a 'model' per thread, i.e. a dedicated widgets layout per thread, adding my own close button would do the job. Ok, this approach doesn't cover the cell closed case but it could act as a 'not so bad' workaround. 
Thanks.
N.


Le jeudi 22 décembre 2016 13:45:48 UTC+1, Sylvain Corlay a écrit :
Hi Nicolas,

I think that this would be a good think to do to handle the case when a widget (model) is completely closed from the front-end. However, is it more subtle than it sounds.

Widgets implement a MVC pattern. The Widget object on the Python side is synchronized with a Javascript "Model". The kernel has no notion of view, or how many views exist for a given model. This design is a consequence of the agnosticity of the architecture to the front-end. The kernel should not know the nature of the (possibly multiple) clients that are connected to it.

In the notebook, the X button only closes a view from the document. Destroying a view does not mean that the widget model is destroyed and triggers no action in the backend.

Sylvain

On Wed, Dec 21, 2016 at 12:17 AM, <nlecle...@gmail.com> wrote:
Hi all,

I need to stop a thread running in the background when the associated interface (i.e. main ipywidget) is closed or when the associated cell is deleted. Not doing so would lead to a bunch of zombie threads after a while. So my questions are:

Is there a way to be notified when the user click on close button of a ipywiget? 
I tried the 'observe' way but it doesn't seem to work - the callback is not called when I close the widget.

As a workaround, hiding the 'X' button could also be a solution cause I can provide my own 'close' button. 
Is it possible to hide the default X button?

Concerning the cells, is there a way to be notified when a specific cell is removed from the notebook? 

Thanks for your help,
Nicolas

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages