John Kitchin
John Kitchin

Reputation: 2433

How do you save the state of a widget in a Jupyter notebook?

I have a radio button widget in a Jupyter notebook and I want to save the selected state, preferrably in the notebook json. That doesn't seem to be happening when I save the notebook. The state gets lost and reset when you reopen the notebook. Is there a way to save the state and have it reload?

Upvotes: 8

Views: 2252

Answers (1)

jayveesea
jayveesea

Reputation: 3199

To save a widget state in a jupyter notebook use Save Notebook Widget State menu item (Widgets>Save Notebook Widget State). From ipywidgets:

A notebook file may be saved with the current widget state as metadata. This allows the notebook file to be rendered with rendered widgets

enter image description here

Upvotes: 1

Related Questions