question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ipywidgets saves new entries to `metadata.widgets.state` on execute and notebook displays a widget for each entry on reload

See original GitHub issue

I 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):

ipywidgets-not-clearing-issue

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
gnestorcommented, Dec 16, 2016

Thank you, Sylvain! 🙏

1reaction
SylvainCorlaycommented, Dec 16, 2016

OK, this is fixed in master! We have a much better model for widgets persistence now.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found