hello,
in my project:https://github.com/bbfamily/abu
use ipywidgets build UI interface, Everything was fine before on conda env .
but on conda 5.0.0 ipywidgets version 7.0.0 final
Resulting in each use IPython.display.clear_output, clear ervery thing in result, include ipywidgets built UI interface.
In ipywidgets 7, the widgets are one of the outputs of the cell, just like any other outputs. That means that clearing the cell output will clear the widgets.
If you'd like to clear only a portion of output, we suggest you capture that output using an Output widget:
from ipywidgets import IntSlider, Output
from IPython.display import display
display(IntSlider())
out = Output()
display(out)
with out:
print('hi')
Now out.clear_output() or
from IPython.display import clear_output
with out:
clear_output()
will clear just the things in that output widget.
Thank you for your answer
How do I direct stderr to an output widget?
import random
from IPython.display import clear_output
from IPython.display import display
button = widgets.Button(description="Click Me!")
output = widgets.Output()
display(button)
out = Output()
display(out)
def on_button_clicked(b):
with out:
clear_output(True)
print("Button clicked.",round(random.uniform(0, 1),3))
button.on_click(on_button_clicked)
Thanks @itsergiu! @arjunkirpal, see also https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html#Debugging-errors-in-callbacks-with-the-output-widget
Most helpful comment
In ipywidgets 7, the widgets are one of the outputs of the cell, just like any other outputs. That means that clearing the cell output will clear the widgets.
If you'd like to clear only a portion of output, we suggest you capture that output using an Output widget:
Now
out.clear_output()orwill clear just the things in that output widget.