Since clear output doesn't clear widgets, we need a clear widgets action in the Widget menu.
Also, perhaps the extension should hook up to Clear All Output, such that it also clears widgets. I haven't run into a case where that's not what I want, but it may exist.
馃憤
I agree that it would be better to hook it up to clear all output. In any case, it is the behavior in jupyterlab.
_Please_ clear the widget state for Clear All Output. :-) Now that we have started to use ipywidgets more heavily, we're having tons of trouble with how it interacts with git. We store cleared notebooks under revision control, but the widget state (specifically, "views") is clogging up everything. E.g. I was just working with a notebook that has 573 lines of JSON, and every time I run it the JSON gets filled up with 3,400 lines of widget state that doesn't appear to achieve anything that I can see. So I end up having to manually edit the JSON before committing any changes to git, which is a very error-prone process. We really want to be able to run a notebook and then clear it and get back the original notebook, along with just the things actually changed, so that we can track the real changes over time.
+1
Related to #607.
+!
Please clear the widget state for Clear All Output. :-) Now that we have started to use ipywidgets more heavily, we're having tons of trouble with how it interacts with git. We store cleared notebooks under revision control, but the widget state (specifically, "views") is clogging up everything. E.g. I was just working with a notebook that has 573 lines of JSON, and every time I run it the JSON gets filled up with 3,400 lines of widget state that doesn't appear to achieve anything that I can see. So I end up having to manually edit the JSON before committing any changes to git, which is a very error-prone process. We really want to be able to run a notebook and then clear it and get back the original notebook, along with just the things actually changed, so that we can track the real changes over time.
For whoever implements this, the above comment is a different issue than clearing outputs. The above comment is about not storing state in the notebook, which is covered in #638. This issue is about clearing outputs.
OK, so this is a widgetsnbextension thing. In the legacy notebook, the cleanest thing we can do is remove the widgetsareas from the DOM. I will fix this tomorrow.
Changing issue title to reflect the discussion above - that we should just clear widgets when a cell's output is cleared
I'm working on this...
Edit: PR at #1098
Hi, is there a way of not clearing the widgets when clear_output() is invoked? I am using a button widget to display several Bokeh and BQplot plots but I would like to refresh the output each time I press the button. I was using clear_output() in Ipywidgets 6.0 but in v7.0 but it now clears the widgets as well as the old plots. Any ideas would be appreciated.
I found a way around it.
1) I invoke clear_output() which now clears all widgets and plots
2) Call widgets.VBox([..... etc]) to redisplay all the old widgets
3) Display new plots using show(x)/display(x) or whatever.
It seems obvious on hindsight.
Most helpful comment
Hi, is there a way of not clearing the widgets when clear_output() is invoked? I am using a button widget to display several Bokeh and BQplot plots but I would like to refresh the output each time I press the button. I was using clear_output() in Ipywidgets 6.0 but in v7.0 but it now clears the widgets as well as the old plots. Any ideas would be appreciated.