Can't seem to re-use the notebook toolbar factory

Hiya all

I’m working on the jlab4 extension for jupytext
I’m almost there, except for the toolbar that (most of the time) fails to show up, and so I’m getting this:
a regular ipynb notebook on top, and a jupytext notebook below

I could use some help with that; I have tracked this down in this issue

and it appears the culprit may be the way we create the NotebookWidgetFactory in https://github.com/mwouts/jupytext/blob/6747cd6abe61b52ba8bd87ec0b374160f50e4b04/packages/labextension/src/index.ts#L510
(in any case notebookFactory.toolbarFactory is always undefined)

so I guess the short version is, what is the right way for this extension - which primarily wants to mimick the usual notebook widget - to initialize its toolbar so it gets just the same as if it were a regular notebook widget


I might be able to make deeper progress on this if I was able to debug the jupyterlab code - like, setting breakpoints - but my skills are limited here, so any hint in that direction would be helpful as well

thanks in advance

Hey @parmentelat

There is no more default notebook toolbar factory as it can be customized through the settings.

To build the toolbar for Jupytext, I guess you can re-use the same parameters as the on for the notebook widget factory; see

See also the documentation: Common Extension Points — JupyterLab 4.0.3 documentation

1 Like

thanks for the feedback!

I’ve come up with this:

this is part of restore notebook toolbar under jlab4 - fix for issue #1107 by parmentelat · Pull Request #1109 · mwouts/jupytext · GitHub

@fcollonval would you care to do a quick review ?

it almost works fine, except for one corner case: if I pour into the mix an extension that adds buttons in the toolbar, then the added buttons do not show up, in general, in the Jupytext Notebook widget (they do show up but only in widgets that are restored as part of the workspace restoration)

in any case this is already much better, so many thanks @fcollonval for pointing me in the right direction