本文整理汇总了TypeScript中jupyter-js-ui/lib/dialog.showDialog函数的典型用法代码示例。如果您正苦于以下问题:TypeScript showDialog函数的具体用法?TypeScript showDialog怎么用?TypeScript showDialog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showDialog函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: trustNotebook
function trustNotebook(model: INotebookModel, host?: HTMLElement): Promise<void> {
// Do nothing if already trusted.
let cells = model.cells;
let trusted = true;
for (let i = 0; i < cells.length; i++) {
let cell = cells.get(i);
if (!cell.getMetadata('trusted').getValue()) {
trusted = false;
}
}
if (trusted) {
return Promise.resolve(void 0);
}
return showDialog({
host: host || document.body,
body: TRUST_MESSAGE,
title: 'Trust this notebook?'
}).then(result => {
if (result.text === 'OK') {
for (let i = 0; i < cells.length; i++) {
let cell = cells.get(i);
cell.getMetadata('trusted').setValue(true);
}
}
});
}
示例2: selectKernel
function selectKernel(host: HTMLElement, kernelName: string, specs: IKernelSpecIds): Promise<string> {
let selector = document.createElement('select');
let options: HTMLOptionElement[] = [];
for (let name in specs.kernelspecs) {
let option = document.createElement('option');
option.value = name;
option.text = specs.kernelspecs[name].spec.display_name;
options.push(option);
}
options.sort((a, b) => { return a.text.localeCompare(b.text); });
for (let option of options) {
selector.appendChild(option);
}
if (kernelName !== 'unknown') {
selector.value = kernelName;
} else {
selector.value = specs.kernelspecs[specs.default].spec.display_name;
}
return showDialog({
title: 'Select Kernel',
host,
body: selector
}).then(result => {
if (result.text === 'OK') {
return selector.value;
}
return null;
});
}
示例3: selectKernel
function selectKernel(host: HTMLElement, model: INotebookModel, specs: IKernelSpecIds): Promise<IKernel> {
let selector = document.createElement('select');
let options: HTMLOptionElement[] = [];
for (let name in specs.kernelspecs) {
let option = document.createElement('option');
option.value = name;
option.text = specs.kernelspecs[name].spec.display_name;
options.push(option);
}
options.sort((a, b) => { return a.text.localeCompare(b.text); });
for (let option of options) {
selector.appendChild(option);
}
if (model.session) {
selector.value = model.session.kernel.name;
} else if (model.metadata && model.metadata.kernelspec) {
selector.value = model.metadata.kernelspec.name;
} else {
selector.value = specs.kernelspecs[specs.default].spec.display_name;
}
return showDialog({
title: 'Select Kernel',
host,
body: selector
}).then(result => {
if (result.text === 'OK') {
if (model.session.kernel.name !== selector.value) {
return model.session.changeKernel(selector.value);
}
}
return model.session.kernel;
});
}
示例4: showDialog
handler: () => {
let msg = 'The quick brown fox jumped over the lazy dog'
showDialog({
title: 'Cool Title',
body: msg,
buttons: [okButton]
});
}
示例5: dropdownDemo
/**
* Create a non-functional drop down demo.
*/
function dropdownDemo(): void {
let selector = document.createElement('select');
let option0 = document.createElement('option');
option0.value = 'python';
option0.text = 'Python 3';
selector.appendChild(option0);
let option1 = document.createElement('option');
option1.value = 'julia';
option1.text = 'Julia';
selector.appendChild(option1);
showDialog({
title: 'Select Kernel',
body: selector,
});
}
示例6: dialogDemo
/**
* Create a non-functional dialog demo.
*/
function dialogDemo(): void {
let body = document.createElement('div');
let input = document.createElement('input');
input.value = 'Untitled.ipynb'
let selector = document.createElement('select');
let option0 = document.createElement('option');
option0.value = 'python';
option0.text = 'Python 3';
selector.appendChild(option0);
let option1 = document.createElement('option');
option1.value = 'julia';
option1.text = 'Julia';
selector.appendChild(option1);
body.appendChild(input);
body.appendChild(selector);
showDialog({
title: 'Create new notebook',
body,
});
}