manzt / anywidget

reusable widgets made easy
https://anywidget.dev
MIT License
490 stars 39 forks source link

Open In Panel #530

Closed psychemedia closed 6 months ago

psychemedia commented 7 months ago

Is there a straightforward way of creating an anywidget wrapped widget in its own panel?

For example, if the widget is a chart object that you want to add layers by executing code in different cells, it might be useful to open the object into its own panel rather than in cell output.

I suppose a workaround is to open the widget into cell output and then use Jupyterlab-sidecar (if that extension still works?) to "rip" the widget into a separate panel.

manzt commented 7 months ago

Hi there. Unfortunately, the idea of an output panel or area is managed by the Jupyter environment, and not something managed by anywidget itself.

In JupyterLab, you can right click to the left of an output cell and select "Create New View for Output Cell" or use sidecar.

image

psychemedia commented 6 months ago

With sidecar regularly in a state of disrepair, another alternative might be ipylab:

%pip install -q ipylab

from ipylab import JupyterFrontEnd, Panel, SplitPanel

app = JupyterFrontEnd()
panel = Panel()
panel.children = [WIDGET]

# Open a new panel containing the widget:
app.shell.add(panel, 'main', { 'mode': 'split-right' })