ipywidgets saves new entries to `metadata.widgets.state` on execute and notebook displays a widget for each entry on reload
See original GitHub issueI am using ipywidgets 4.0 with Jupyter 1.0 (IPython 4.0) in Anaconda 64-bits v4.0 (Python 2.7).
When multiple widgets are displayed, if the user starts the cell again, the widgets seem to be completely cleared and replaced by the new instances. However, if the user saves the notebook, then reopens it (eg, by refreshing the page), the old widgets that should have been cleared reappear (except the first one for each cell execution). This is because ipywidgets cleans up the first widget from the log, but not the subsequent ones.
Code to reproduce the issue:
import ipywidgets
from ipywidgets import IntProgress
from IPython.display import display
from time import sleep
p = IntProgress(min=0, max=100, description="First bar is deleted")
p2 = IntProgress(min=0, max=100, description="Second bar always stays")
display(p)
display(p2)
p.bar_style = 'info'
for i in xrange(100):
p.value = p.value + 1
p2.value = p2.value + 1
sleep(0.01)
Here is a demonstration of the issue (note that it doesn’t matter if the cell execution completes or if it is stopped by user, in both cases the widgets will reappear):
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Embedding Jupyter Widgets in Other Contexts than the ...
A notebook file may be saved with the current widget state as metadata. This allows the notebook file to be rendered with rendered...
Read more >How do you save the state of a widget in a Jupyter notebook?
To save a widget state in a jupyter notebook use Save Notebook Widget State menu item (Widgets>Save Notebook Widget State). From ipywidgets:.
Read more >Interactive data analysis with figurewidget ipywidgets in Python
Let's assign the widgets that we're going to be using in our app. In general all these widgets will be used to filter...
Read more >Bring your Jupyter Notebook to life with interactive widgets
How to create dynamic dashboards in a Jupyter notebook using ipywidgets. A step by step tutorial on how to make your notebooks interactive ......
Read more >ipywidgets Documentation - Read the Docs
Embedding Jupyter Widgets in Other Contexts than the Notebook . ... Each time a widget is displayed, a new representation of.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you, Sylvain! 🙏
OK, this is fixed in master! We have a much better model for widgets persistence now.