jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.13k stars 949 forks source link

clear_out() and then display(),jupyter will show plain text representation. #3188

Open cashewnut opened 3 years ago

cashewnut commented 3 years ago

Description

When I drag a IntSlider, I want to clear the output(plot) first and redisplay the IntSlider, but the IntSlider can't be shown.

Reproduce

environments Pycharm 2011.1 image

  1. run next code
    
    def handler2(change):
    clear_output(wait=True)
    display(tests)

tests = widgets.Dropdown( options=task_ids, description='test:', disabled=False, )

tests.observe(handler2, names='value') display(tests)


![image](https://user-images.githubusercontent.com/14501861/116351841-dd4d8200-a826-11eb-9a43-8fed15d97a07.png)
2. select another option such as 40:
![image](https://user-images.githubusercontent.com/14501861/116351932-02da8b80-a827-11eb-9257-999de91106cb.png)
3. but if I comment ```clear_output```
![image](https://user-images.githubusercontent.com/14501861/116351991-1b4aa600-a827-11eb-8eda-dd07a83bcbde.png)

<!--Describe step-by-step instructions to reproduce the behavior-->

<!--Describe how you diagnosed the issue. See the guidelines at
 https://jupyterlab.readthedocs.io/en/latest/getting_started/issue.html -->

## Expected behavior

<!--Describe what you expected to happen-->

## Context

<!--Complete the following for context, and add any other relevant context-->

- ipywidgets version <!-- import ipywidgets; print(ipywidgets.__version__)-->
- Operating System and version:
- Browser and version:

<details><summary>Troubleshoot Output</summary>
<pre>
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
</pre>
</details>

<details><summary>Command Line Output</summary>
<pre>
Paste the output from your command line running `jupyter lab` (or `jupyter notebook` if you use notebook) here, use `--debug` if possible.
</pre>
</details>

<details><summary>Browser Output</summary>
<pre>
Paste the output from your browser Javascript console here.
</pre>
</details>

### If using JupyterLab
- JupyterLab version:

<details><summary>Installed Labextensions</summary>
<pre>
Paste the output from your command line running `jupyter labextension list`.
</pre>
</details>
JosephHodes commented 1 year ago

clear_output no matter where you put it clears the output