ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

Single widget manager per kernel

Open fleming79 opened this issue 1 year ago • 1 comments

Replaces https://github.com/jupyter-widgets/ipywidgets/pull/3920.

Features:

  • Widgets can render anywhere the WidgetRenderer can be accessed (anywhere the global rendermime or clones work).
  • Correctly indicates when comms is disconnected.
  • Re-renders widgets when comms is restored.
  • Easier to manage and find widgets - the KernelWidgetManager.

Significant changes

  • The KernelWidgetManager is a single instance per kernel by the kernel ID.
  • The KernelWidgetManager stores and creates widgets.
  • The default rendermime will actively search for the [Kernel]WidgetManager that owns the widget model.
  • WidgetManager (not to be confused with KenelWidgetManager) has been re-purposed to track the renderers belonging to a session context and set the KernelWidgetManager when the kernel is loaded. WidgetManager informs the renderer that the [Kernel]WidgetManager is pending.
  • Re-rendering on demand.

Notebooks and Consoles can share widgets

image

When the notebook is closed ipwidgets takes over comms and re-renders the widget.

image

Shutting down the kernel breaks the connection (note the red paper clips)

image

Re-opening the notebook now gives a message

Model not found for this kernel: AppLayout(children=(HTML(value='<h1>Fictional World Weather</h1>', layout=Layout(grid_area='header', height='a…

image

fleming79 avatar May 27 '24 11:05 fleming79