jupyterlab / jupyterlab

JupyterLab computational environment.
https://jupyterlab.readthedocs.io/
Other
13.81k stars 3.12k forks source link

Example of standalone app with ipywidgets support #16227

Open pplonski opened 3 weeks ago

pplonski commented 3 weeks ago

Problem

There are available examples of how to use Jupyter components to build apps. However, they do not support ipwyidgets.

Proposed Solution

It would be fantastic if there will be an example of how to reuse Jupyter components to build standalone apps with ipywidgets support. Thank you!

JasonWeill commented 2 weeks ago

@pplonski Thanks for opening this issue! Can you please share the examples you're referring to about building apps using Jupyter components? Thanks!

pplonski commented 2 weeks ago

Thanks @JasonWeill for prompt response. I was referring to examples folder and example apps like examples/app or examples/notebook, it would be fantastic if there will be similar example on how to build your own notebook app with support of ipywidgets.

JasonWeill commented 2 weeks ago

@pplonski Got it, thank you for clarifying!

erkin98 commented 2 weeks ago

@pplonski what do you mean by with support of ipywidgets?

pplonski commented 2 weeks ago

Hi @erkin98,

Right now when you try to run example app (exmaples/notebook) and import ipywidgets and try some widget in the cell, you don't see the widget only text representation .

jtpio commented 1 week ago

One way would be to add the @jupyter-widgets/jupyterlab-manager package to the list of dependencies in that examples/notebook demo app, and require it like the other packages so it's loaded on the page. This way, the widgets manager would be built into the app bundle directly, and should enable the use of widgets.

Another way is to add the bootstrap code that loads federated extensions (like in JupyterLab), which would then pick up the widgets manager from the jupyterlab-widgets Python package directly. There is an example for creating a custom app with federated extensions here: https://github.com/jupyterlab/jupyterlab/tree/main/examples/federated.

pplonski commented 1 week ago

Thank you @jtpio, so it looks like there can be added two new examples.