Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ipywidgets with standalone cell view/output #3946

Open
krassowski opened this issue Sep 3, 2024 · 3 comments
Open

Using ipywidgets with standalone cell view/output #3946

krassowski opened this issue Sep 3, 2024 · 3 comments

Comments

@krassowski
Copy link

Problem

It's currently hard to use ipywidgets outside of existing notebook and console widgets. It should not be.

Proposed Solution

Expose registerWidgetHandler? Generalize it to take Notebook | Console | IDisposable argument?

async function registerWidgetHandler(
content: Notebook | CodeConsole,
sessionContext: ISessionContext,
rendermime: IRenderMimeRegistry,
renderers: IterableIterator<WidgetRenderer>,
widgetManagerFactory: () => WidgetManager | KernelWidgetManager
): Promise<DisposableDelegate> {

Additional context

Related to jupyterlab/jupyterlab#16227

@krassowski
Copy link
Author

It is pretty easy to pretend that we have a console and use registerConsoleWidgetManager. It goes like:

registerConsoleWidgetManager(
  {console: {
    sessionContext,
    rendermime,
    disposed: outputArea.disposed
  }} as any,
  chain(widgetOutputs())
)

@martinRenou
Copy link
Member

martinRenou commented Sep 4, 2024

Agreed!

I understand #3922 would go in that direction. Though it may be quite breaking (I only assume, haven't reviewed yet). I'm not sure I like the idea of breaking the APIs, ipywidgets 8 was already quite disruptive.

@fleming79
Copy link

I've been working on the PR jtpio/ipylab#135 for ipylab that uses #3922.

For a per-kernel widget manager the following line enables Ipywidgets for a kernel.

new KernelWidgetManager(sessionContext.session.kernel, rendermime as any);

rendermime is optional and would default to the global rendermime if omitted.

It is foreseeable that widgets could be automatically enabled for any Python kernel started or registered in Jupyterlab.

The screenshots below demonstrate the capabilities of ipylab combined with the per-kernel widget manager.

  • starting kernels
  • creating launcher buttons
  • adding widgets to the main area
  • adding widgets to the side area

I've been using these new features for months in Jupyterlab 4 without major issue. I'm no expert in Jupyterlab or Ipywidgets and would appreciate guidance / collaboration from an expert.

Create launchers

image

Control of Jupyterlab and adding widgets to the main area

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants