Customising Main Menu using extension

Hi, I am looking to customise the Main Menu of Jupyter Lab but I am kinda stuck. I followed the official examples GitHub - jupyterlab/extension-examples: JupyterLab Extensions by Examples, I was able to build and install the main menu extension which adds another option but I am looking to delete certain options from my main menu but I can’t seem to find any documentation related to deletion of items from the main menu. Let me know what I can do to delete certain options from the main menu.

Thank you.

Basically every class/function in JupyterLab and Lumino has generated documentation… but you’ll want to find out where you’re going first.

With the example up and running, your best sources of first-order information will be:

  • your editor’s introspection capabilities to find out what the various members are, and what functions they have
    • this contains the same information as those API sites
  • the live state of the application in the browser tools
    • to see what’s actually on the upstream things you’re working with

In this case: the Menu class is inherited from lumino.

As to how you’d find the IItem you wish to remove (don’t trust the index (because other extensions) or label, becasue i18n), you may have to iterate over them to find the correct one… command is probably reliable, if the thing in question has it. As many of these are dynamic, having your system up and running with the browser debugger is sometimes the only way to get the “truth” of how you might tell things apart.

1 Like

Since JupyterLab 3.2, you can tune the main menu using the settings.

For the main menu, you need to define the menus in SettingsAdvanced Settings EditorMain Menu

To hide an existing item, you need to set disabled to true on it. See that example

If you need something dynamic - the path is the one mentioned by Nick above.

1 Like