JupyterLab - add a subset of commands to sidebar tab

杀马特。学长 韩版系。学妹 提交于 2021-02-10 06:36:20

问题


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://imgur.com/pHlTCLZ


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://imgur.com/a/bQhZNOe

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

来源:https://stackoverflow.com/questions/50691320/jupyterlab-add-a-subset-of-commands-to-sidebar-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!