本文整理汇总了TypeScript中@jupyterlab/apputils.IClientSession类的典型用法代码示例。如果您正苦于以下问题:TypeScript IClientSession类的具体用法?TypeScript IClientSession怎么用?TypeScript IClientSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IClientSession类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: KernelStatus
activate: (
app: JupyterLab,
statusBar: IStatusBar,
notebookTracker: INotebookTracker,
consoleTracker: IConsoleTracker
) => {
// When the status item is clicked, launch the kernel
// selection dialog for the current session.
let currentSession: IClientSession | null = null;
const changeKernel = () => {
if (!currentSession) {
return;
}
currentSession.selectKernel();
};
// Create the status item.
const item = new KernelStatus({
onClick: changeKernel
});
// When the title of the active widget changes, update the label
// of the hover text.
const onTitleChanged = (title: Title<Widget>) => {
item.model!.activityName = title.label;
};
// Keep the session object on the status item up-to-date.
app.shell.currentChanged.connect((shell, change) => {
const { oldValue, newValue } = change;
// Clean up after the old value if it exists,
// listen for changes to the title of the activity
if (oldValue) {
oldValue.title.changed.disconnect(onTitleChanged);
}
if (newValue) {
newValue.title.changed.connect(onTitleChanged);
}
// Grab the session off of the current widget, if it exists.
if (newValue && consoleTracker.has(newValue)) {
currentSession = (newValue as ConsolePanel).session;
} else if (newValue && notebookTracker.has(newValue)) {
currentSession = (newValue as NotebookPanel).session;
} else {
currentSession = null;
}
item.model!.session = currentSession;
});
statusBar.registerStatusItem(
'@jupyterlab/statusbar-extension:kernel-status',
{
item,
align: 'left',
rank: 1,
isActive: () => {
const current = app.shell.currentWidget;
return (
current &&
(notebookTracker.has(current) || consoleTracker.has(current))
);
}
}
);
}
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:67,代码来源:index.ts
示例2:
const changeKernel = () => {
if (!currentSession) {
return;
}
currentSession.selectKernel();
};
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:6,代码来源:index.ts
示例3: async
const changeKernel = async () => {
if (!currentSession) {
return;
}
await currentSession.selectKernel();
};
开发者ID:afshin,项目名称:jupyterlab,代码行数:6,代码来源:index.ts
注:本文中的@jupyterlab/apputils.IClientSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论