Skip to content

Widget rendering in JupyterLab4 and JupyterNotebook7 #3823

Closed
@kolibril13

Description

@kolibril13

Today I was investigating how I can store the state of a widget with the latest Jupyter setups.

I wanted to know:

  • Can I save the widget state?
  • Is there an indicator that shows that the widget-kernel connection is lost?
  • Does the widget render correctly after restarting the Jupyter server?
  • Does the widget render correctly on sphinx with myst-nb?

And here is a summary of my findings:

image

used code:

import ipywidgets
ipywidgets.__version__

ipywidgets.widgets.Button(description="Hello World!")

Key findings from the above chart:

  1. Jupyter Notebook 6.5.4 is a setup where everything works great and there's the option "Save Notebook Widget State".
  2. jlab4 and jn7 have the new option "Save Widget State Automatically". I couldn't find out if that actually works or no.
  3. Jupyter VS Code cannot save widget states, and that's also not planned Save notebook widget state microsoft/vscode-jupyter#4404 .
  4. When I shut down the jupyter server and restart it, the jlab4 and nb7 console says "Error: widget model not found".
    I think making widget rendering possible after a notebook restart in the latest Jupyter environments would be a fantastic improvement. This could impact the widget ecosystem in a very positive way, especially since numerous people in the community have reported similar widget model not found errors:
    Widget state not persisted after kernel restart #3758,
    ipywidgets not renderering without a kernel #3773,
    ipywidgets cannot render when connected to a kernel of another notebook #2628,
    Display image even when restarting notebook. #3183,
    In JupyterLab 4.02, ipywidgets throws error in console on saving widget state. #3790

https://discourse.jupyter.org/t/widgets-not-rendering-after-the-second-time-a-notebook-is-reopened/10631
https://discourse.jupyter.org/t/error-displaying-widget-model-not-found-geemap/11473

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions