Placing widget at arbitrary relative position

Hi,
let’s say, we want to have kind of a traditional north/south/west/east/center layout, where additional widgets fill the margins around the main notebook widget.
When we intend to open a new widget in the “east” region, we’d like to first identify if there is already a widget in this region. If no, the main widget should be split into “center” and “east”. If yes, the new widget should be added as new tab to the existing “east” region.

Does this make sense? How can these steps of identifying the positions of existing widgets before adding a new one be done (conceptually or implementation-wise?

Thanks
Josh

1 Like

Do you want your widgets to be put in the main area where users can drag them, or in the sidebars where they can’t drag them (i.e., the notebook remains central in your app)?

If you want to maintain the layout you describe, add your widgets to the left and right sidebars using the lab shell’s .add(widget, 'left') or .add(widget, 'right') method calls. The bottom region is 'bottom', etc.

You can see examples of this in various extensions that add things to the sidebars, like https://github.com/jupyterlab/jupyterlab/blob/b39a3441e1b32ba1f59b9ff580574e5950112a22/packages/running-extension/src/index.ts#L61