Adding Widgets to Notebook Cells & The Notebook at large

Hi, I’m a little stuck on how to add a widget to a notebook cell. Basically I’d like to add an icon to the left of the input of certain cells (near the input collapse button) that the user can click on, and then watch for clicking. This seems rather simple in principle, so I might be missing something obvious. I was originally hoping for something like an “addWidget” method to exist in the Cell class (https://jupyterlab.github.io/jupyterlab/cells/classes/cell.html#children). It seems like I want to add another “child” to this class, but I’m a bit stuck how to do that. Or is this the wrong way to think about this?

It seems like another option is to completely override the cell type and the cell provider and add my widget in the same way the other cell children are added, but this seems rather heavy handed and would seem to not play well with any other extensions which wanted to do the same.

As a stretch goal, I’d also like to be able to add widgets that sat in the notebook at certain locations but weren’t directly tied to individual cells, but rather groups of sequential cells. This seems a bit more challenging though.

@aquirdTurtle: Are you aware of https://github.com/jupyter-widgets/ipywidgets? It might be easier to use this approach, rather than reinventing the wheel. I have had success using this in standard notebooks, but I am still trying to get it working in jupyterlab.

If you want to hide cell content, you may also consider checking out https://github.com/oschuett/appmode and https://github.com/binder-examples/appmode for an “appmode” for your notebooks.