Closed fleming79 closed 6 months ago
Thanks for opening a PR for this! Was this closed on purpose?
Yes and no.
If there is still the possibility of a per-kernel widget manager I can re-open or make a new PR with updates.
I believe we're still open to refactor the widget manager logic to be more "general" and less tight to the Notebook (or the console). #3004 was merged as-is because it's already an improvement of the current state, but Jason's comments in the PR are still relevant.
This PR is exploring the possibility of a per-kernel widget manager as suggested by @jasongrout in the comments of the recently merged PR: https://github.com/jupyter-widgets/ipywidgets/pull/3004.
This PR follows on from a recent PR https://github.com/jupyter-widgets/ipywidgets/pull/3893, but could be easily re-based independently.
In it's current form, it can render the same widget in notebook[s] and consoles connected to the same kernel. The only requirement being that the KernelWidgetManager is registered to (instantiated with) the kernel.
How it works
KernelWidgetManager
was modified to create only one instance per kernel.id.WidgetManager
was changed to be an interface for notebooks that swaps the notebook (panel) rendermime factory to use the KernelWidgetManager corresponding to the new kernel as the kernel is changed.Other changes
WidgetRenderer
was modified to search for the widget manager of a model_id if the widgetManager wasn't specified.