Skip to content

Instantly share code, notes, and snippets.

@fcollonval
Last active September 5, 2022 08:05
Show Gist options
  • Save fcollonval/facfadcd926621a84556a040aac71a8f to your computer and use it in GitHub Desktop.
Save fcollonval/facfadcd926621a84556a040aac71a8f to your computer and use it in GitHub Desktop.
JupyterLab custom menu

Customized JupyterLab

This is an example of JupyterLab UI customization.

Test it online: Binder

Requirement: JupyterLab >= 3.4

What is demonstrated?

  • Context menu:

    • Disable the context menu entry Create console (available normally when right clicking on a panel tab).
  • Main menu:

    • Disable Run menu
    • Remove command Open path from the file menu
  • Toolbars:

    • Notebook:
      • Remove button Restart and run all
      • Add button Clear all outputs
    • Cell:
      • Add a clear cell output button
{
"@jupyterlab/application-extension:context-menu": {
"contextMenu": [
{
"command": "filemenu:create-console",
"selector": "[data-type=\"document-title\"].jp-mod-current",
"disabled": true
}
]
},
"@jupyterlab/mainmenu-extension:plugin": {
"menus": [
{
"id": "jp-mainmenu-run",
"disabled": true
},
{
"id": "jp-mainmenu-tabs",
"rank": 1100
},
{
"id": "jp-mainmenu-file",
"items": [
{
"command": "filebrowser:open-path",
"disabled": true
}
]
}
]
},
"@jupyterlab/notebook-extension:panel": {
"toolbar": [
{ "name": "restart-and-run", "disabled": true },
{ "name": "clear-all-outputs", "command": "notebook:clear-all-cell-outputs" }
]
},
"@jupyterlab/cell-toolbar-extension:plugin": {
"toolbar": [
{ "name": "clear-output", "command":"notebook:clear-cell-output", "icon": "ui-components:close" }
]
}
}
#!/usr/bin/env bash
set -eux
mkdir -p ${NB_PYTHON_PREFIX}/share/jupyter/lab/settings
cp overrides.json ${NB_PYTHON_PREFIX}/share/jupyter/lab/settings
jupyterlab>=3.4.0rc0,<4.0.0a0
@fcollonval
Copy link
Author

Presumably the error is due to invalid JSON syntax (all strings must be double quoted in JSON):

{
  "@jupyterlab/docmanager-extension:plugin": {
    "defaultViewers": 
      {
        "markdown": "Markdown Preview"
      }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment