小编Tre*_*ock的帖子

如何获取 JupyterLab 中当前活动的笔记本名称?

我正在 JupyterLab 中创建服务器端扩展,并且一直在寻找一种方法来获取 index.ts 文件中当前活动的笔记本名称。我发现这个现有的扩展可以获取当前活动的选项卡名称,ILabShell并将浏览器选项卡设置为具有相同的名称。就我而言,我将使用笔记本工具栏上的按钮触发该过程,因此活动选项卡将始终是笔记本。activate但是,当我尝试使用扩展部分中的代码时,我得到了TypeError: labShell.currentChanged is undefinedwherelabShell是 的实例ILabShell。该扩展不支持 JupyterLab 3.0+,所以我认为这是问题的一部分。然而,currentChangedfor在这里ILabShell被明确定义。如果我可以改变什么以使其发挥作用怎么办?还有其他方法可以完成我想做的事情吗?我知道类似这样的事情可以在笔记本中获取笔记本名称,但这并不是我想要做的。

Windows 10、
节点 v14.17.0、
npm 6.14.13、
jlpm 1.21.1、
jupyter lab 3.0.14

我使用此示例服务器扩展作为模板:https ://github.com/jupyterlab/extension-examples/tree/master/server-extension

从现有扩展的 index.ts 文件获取当前选项卡名称:

import {
  ILabShell,
  JupyterFrontEnd,
  JupyterFrontEndPlugin
} from '@jupyterlab/application';

import { Title, Widget } from '@lumino/widgets';

/**
 * Initialization data for the jupyterlab-active-as-tab-name extension.
 */
const extension: JupyterFrontEndPlugin<void> = {
  id: 'jupyterlab-active-as-tab-name',
  autoStart: true, …
Run Code Online (Sandbox Code Playgroud)

jupyter jupyter-notebook jupyter-lab

5
推荐指数
1
解决办法
1235
查看次数

标签 统计

jupyter ×1

jupyter-lab ×1

jupyter-notebook ×1