Skip to main content

A JupyterLab UI Tour inspired by @cdat/jupyterlab-tutorial.

Project description

jupyterlab-tour

Extension status Github Actions Status Binder npm PyPI conda-forge

A JupyterLab UI Tour based on react-joyride.

demo

Install

pip install jupyterlab-tour

or

conda install -c conda-forge jupyterlab-tour

Features

This extension has the following features:

  • Default tours:
    • Welcome tour
    • Notebook tour
    • User-defined features in Settings
  • Toast proposing to start a tour - to experienced users the need to exit each time the tour.
  • If a tour has already be seen by the user, this is saved in the state database. So you can start tour on event only if the user have not seen it; e.g. the welcome tour is launched at JupyterLab start except if the user have seen it.

The state is cleaned if this extension is updated

  • Tooltip are styled using JupyterLab theming system
  • Commands to add and launch tours
  • Through the tour manager (ITourManager extension token), add, modify or delete a tour
  • Connect to tour events through signals
  • Override the default style (and options) for the tour separately

This extension is inspired by @cdat/jupyterlab-tutorial licensed under BSD 3-Clause License with Copyright (c) 2020, Lawrence Livermore National Security, LLC.

Requirements

  • JupyterLab >= 3.0

For JupyterLab 2.x, have look there.

For developers, the API has changed between v3 (for JupyterLab 3) and v2 (for JupyterLab 2).

How to add a tour with Advanced Settings

As a user of JupyterLab, after you've installed jupyterlab-tour, you can create your own Tours as data.

  • Open the JupyterLab Advanced Settings panel Ctrl+,
  • Select Tours from list of settings groups
  • In the editor, create JSON(5) compatible with the react-joyride data model
  • The Tour will be available from the Help Menu, as well as the Command Palette

A simple Tour

For example, to show a glowing button on the Jupyter logo, which reveals an orange overlay when pressed:

// json5 can have comments
{
  "tours": [
    {
      "id": "my-tour",
      "label": "My First Tour",
      // steps are required, and have many, many options
      "steps": [
        {"target": "#jp-MainLogo", "content": "Look at this!"}
      ],
      // below here not required!
      "options": {
        "styles": {
          "options": {
            // you can use jupyterlab theme variables
            "backgroundColor": "var(--jp-warn-color0)"
          }
        }
      }
    }
  ]
}

Shipping a Tour to Binder

On Binder, and elsewhere, you can store the above (without comments) in an overrides.json file and put it in the right place, e.g. {sys.prefix}/share/jupyter/lab/settings/overrides.json. When JupyterLab is next opened, those overrides will become the defaults, and your tour will be available.

An example overrides.json might look like:

{
  "jupyterlab-tour:user-tours": {
    "tours": [
      // that tour up there!
    ]
  }
}

How to add tour for my JupyterLab extension

As an extension developer, there are two methods to add a tour: the easiest is to use JupyterLab commands and the advanced version is to request this extension token ITourManager.

Add easily a tour

const { commands } = app;
// Add a tour - returns the tour or null if something went wrong
const tour = (await app.commands.execute('jupyterlab-tour:add', {
  tour: { // Tour must be of type ITour - see src/tokens.ts
    id: 'test-jupyterlab-tour:welcome',
    label: 'Welcome Tour',
    hasHelpEntry: true,
    steps: [  // Step must be of type IStep - see src/tokens.ts
      {
        content:
          'The following tutorial will point out some of the main UI components within JupyterLab.',
        placement: 'center',
        target: '#jp-main-dock-panel',
        title: 'Welcome to Jupyter Lab!'
      },
      {
        content:
          'This is the main content area where notebooks and other content can be viewed and edited.',
        placement: 'left-end',
        target: '#jp-main-dock-panel',
        title: 'Main Content'
      }
    ],
    // can also define `options`
  }
})) as ITourHandler;
if ( tour ) {
  app.commands.execute('jupyterlab-tour:launch', {
    id: 'test-jupyterlab-tour:welcome',
    force: false  // Optional, if false the tour will start only if the user have not seen or skipped it
  })
}

One example is available on Mamba navigator. Test it on binder.

If you want to react to step changes to trigger elements of the UI (like opening sidebar), you can connect to the stepChanged signal. Building from the previous example, this snippet will open the filebrowser after the first step.

  tour.stepChanged.connect((_, data) => {
    switch (data.type) {
      case 'step:after':
        if (data.step.target === '#jp-main-dock-panel') {
          commands.execute('filebrowser:activate');
        }
        break;
    }
  });

data is an object of type CallbackProps.

Disabling the User and Default Tours

If you only wish to see the default Welcome and Notebook tours, or ones defined by users, they can be disabled via the command line or a well-known file.

The examples below disable all tours not provided by third-party extensions. Adding jupyterlab-tour:plugin to either of these will disable tours altogether!

Disabling Tours from the Command Line

From the command line, run:

jupyter labextension disable "jupyterlab-tour:user-tours"
jupyter labextension disable "jupyterlab-tour:default-tours"

Disabling Tours with pageConfig.json

Create a pageConfig.json and put it in the right place, e.g. {sys.prefix}/etc/jupyter/labconfig/pageconfig.json and add the plugin IDs to disabledExtensions.

{
  "disabledExtensions": {
    "jupyterlab-tour:user-tours": true,
    "jupyterlab-tour:default-tours": true,
  }
}

Uninstall

pip uninstall jupyterlab-tour

or

conda remove -c conda-forge jupyterlab-tour

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the jupyterlab-tour directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm run build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the jlpm run build command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab-tour-3.1.4.tar.gz (93.9 kB view details)

Uploaded Source

Built Distribution

jupyterlab_tour-3.1.4-py3-none-any.whl (154.8 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab-tour-3.1.4.tar.gz.

File metadata

  • Download URL: jupyterlab-tour-3.1.4.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for jupyterlab-tour-3.1.4.tar.gz
Algorithm Hash digest
SHA256 f1d80ec906f689134d259203caf281ea53b8c2353c4a265c29947b557e009229
MD5 144e75afdcf20e16f36f29f0a5c286ba
BLAKE2b-256 7f89fd2963e13f3771640840460c537360e6c674a34ed88ad0f013eeb4663a75

See more details on using hashes here.

File details

Details for the file jupyterlab_tour-3.1.4-py3-none-any.whl.

File metadata

  • Download URL: jupyterlab_tour-3.1.4-py3-none-any.whl
  • Upload date:
  • Size: 154.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for jupyterlab_tour-3.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f55a3648529b0ce63c77e790c2605449a746fc2bb7e0b349dc83e8afa669b5ec
MD5 55fcdd07bdb9bd94e89537c8152b781c
BLAKE2b-256 410b40308b6998fbcb1cee28d662bc9bef1bac40ce9861a81ab8ca305d205e48

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page