Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 543
John Kitchin Avatar asked Jan 28 '17 17:01

John Kitchin


People also ask

How do you save changes in Jupyter notebook?

Saving a Jupter notebook Saving your edits is simple. There is a disk icon in the upper left of the Jupyter tool bar. Click the save icon and your notebook edits are saved.

What is a Jupyter notebook widget?

Jupyter Widgets are interactive browser controls for Jupyter notebooks. Examples include: Basic form controls like sliders, checkboxes, text inputs. Container controls like tabs, accordions, horizontal and vertical layout boxes, grid layouts. Advanced controls like maps, 2d and 3d visualizations, datagrids, and more.

Where do Jupyter notebooks save?

Configuration files Config files are stored by default in the ~/. jupyter directory. Set this environment variable to use a particular directory, other than the default, for Jupyter config files.

How do I install Jupyter widgets?

Simply install the python ipywidgets package with pip (pip install ipywidgets==7.6. 0) or conda/mamba (conda install -c conda-forge ipywidgets=7.6. 0) and ipywidgets will automatically work in classic Jupyter Notebook and in JupyterLab 3.0.


1 Answers

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

like image 69
jayveesea Avatar answered Oct 10 '22 03:10

jayveesea