3

I have some experience with Jupyter Notebook tweaking, but not with JupyterLab.

Basically, I want to add a subset of commands to a side tab. Let's say I've registered the command "sample" under the heading "DTLA"

    function addCommands(app: JupyterLab, tracker: ICommandPalette): void {
    const category = 'DTLA';
    let command = CommandIDs.sample;

    app.commands.addCommand(command, {
        label: 'sample',
        execute: () => { console.log('hellow!'); }
    });
    tracker.addItem({ command, category })

    }

    /**
    * The command IDs used by the application plugin.
    */
    namespace CommandIDs {
    export
    const sample: string = 'application:sample';
    }

https://i.stack.imgur.com/HUSRG.jpg


now i want to put it into its own sidebar tab, which i can create just fine.

    /**
    * Activate the extension.
    */
    function activateext(
    app: JupyterLab,
    docmanager: IDocumentManager,
    editorTracker: IEditorTracker,
    restorer: ILayoutRestorer,
    notebookTracker: INotebookTracker,
    rendermime: IRenderMimeRegistry,
    palette: ICommandPalette,
    ): IExt {
    // Create the ext widget.
    const ext = new Ext({docmanager, rendermime, palette});
    // Create the ext registry.
    const registry = new ExtRegistry();
    //add commands
    addCommands(app, palette);


    // Add the ext to the left area.
    ext.title.label = 'DTLA';
    ext.id = 'table-of-contents';
    app.shell.addToLeftArea(ext, {rank: 700});

    // Add the ext widget to the application restorer.
    restorer.add(ext, 'juputerlab-ext');

    return registry;
    }

    export default extension;

https://i.stack.imgur.com/5CUku.jpg

so, how do i attach commands to the new sidebar?

SQLesion
  • 165
  • 2
  • 9

0 Answers0