JupyterLab - 将一部分命令添加到侧边栏选项卡

时间:2018-06-05 02:51:03

标签: jupyter jupyter-lab

我有一些Jupyter Notebook调整的经验,但不是JupyterLab。

基本上,我想在侧面标签中添加一个命令子集。让我们说我已经注册了命令" sample"标题为#DT;"

    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

现在我想将它放入自己的侧边栏标签,我可以创建它。

    /**
    * 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

那么,如何将命令附加到新的侧边栏?

0 个答案:

没有答案