本文整理匯總了TypeScript中@jupyterlab/mainmenu.KernelMenu.addGroup方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript KernelMenu.addGroup方法的具體用法?TypeScript KernelMenu.addGroup怎麽用?TypeScript KernelMenu.addGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@jupyterlab/mainmenu.KernelMenu
的用法示例。
在下文中一共展示了KernelMenu.addGroup方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createKernelMenu
export function createKernelMenu(app: JupyterLab, menu: KernelMenu): void {
const commands = menu.menu.commands;
commands.addCommand(CommandIDs.interruptKernel, {
label: 'Interrupt Kernel',
isEnabled: Private.delegateEnabled(
app,
menu.kernelUsers,
'interruptKernel'
),
execute: Private.delegateExecute(app, menu.kernelUsers, 'interruptKernel')
});
commands.addCommand(CommandIDs.restartKernel, {
label: 'Restart Kernel…',
isEnabled: Private.delegateEnabled(app, menu.kernelUsers, 'restartKernel'),
execute: Private.delegateExecute(app, menu.kernelUsers, 'restartKernel')
});
commands.addCommand(CommandIDs.restartKernelAndClear, {
label: () => {
const noun = Private.delegateLabel(app, menu.kernelUsers, 'noun');
const enabled = Private.delegateEnabled(
app,
menu.kernelUsers,
'restartKernelAndClear'
)();
return `Restart Kernel and Clear${enabled ? ` ${noun}` : ''}…`;
},
isEnabled: Private.delegateEnabled(
app,
menu.kernelUsers,
'restartKernelAndClear'
),
execute: Private.delegateExecute(
app,
menu.kernelUsers,
'restartKernelAndClear'
)
});
commands.addCommand(CommandIDs.changeKernel, {
label: 'Change Kernel…',
isEnabled: Private.delegateEnabled(app, menu.kernelUsers, 'changeKernel'),
execute: Private.delegateExecute(app, menu.kernelUsers, 'changeKernel')
});
commands.addCommand(CommandIDs.shutdownKernel, {
label: 'Shutdown Kernel',
isEnabled: Private.delegateEnabled(app, menu.kernelUsers, 'shutdownKernel'),
execute: Private.delegateExecute(app, menu.kernelUsers, 'shutdownKernel')
});
commands.addCommand(CommandIDs.shutdownAllKernels, {
label: 'Shutdown All Kernels…',
isEnabled: () => {
return app.serviceManager.sessions.running().next() !== undefined;
},
execute: () => {
showDialog({
title: 'Shutdown All?',
body: 'Shut down all kernels?',
buttons: [
Dialog.cancelButton(),
Dialog.warnButton({ label: 'SHUTDOWN' })
]
}).then(result => {
if (result.button.accept) {
return app.serviceManager.sessions.shutdownAll();
}
});
}
});
const restartGroup = [
CommandIDs.restartKernel,
CommandIDs.restartKernelAndClear,
CommandIDs.restartAndRunAll
].map(command => {
return { command };
});
menu.addGroup([{ command: CommandIDs.interruptKernel }], 0);
menu.addGroup(restartGroup, 1);
menu.addGroup(
[
{ command: CommandIDs.shutdownKernel },
{ command: CommandIDs.shutdownAllKernels }
],
2
);
menu.addGroup([{ command: CommandIDs.changeKernel }], 3);
}