Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Frederic Collonval
committed
May 23, 2019
1 parent
71d21ce
commit dc589e0
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
User Interface Helpers | ||
---------------------- | ||
|
||
JupyterLab comes with helpers to show or request simple information to user. | ||
Those speed up development and ensure a common look & feel. | ||
|
||
Dialogs | ||
~~~~~~~ | ||
|
||
File Dialogs | ||
'''''''''''' | ||
|
||
Two helper functions to ask a user to open a file or a directory are | ||
available in the ``filebrowser`` package under the namespace ``FileDialog``. | ||
|
||
Here is an example to request a file. | ||
|
||
.. code:: typescript | ||
const dialog = FileDialog.getExistingDirectory({ | ||
manager, // IDocumentManager | ||
filter: model => model.type == 'notebook' // optional (model: Contents.IModel) => boolean | ||
}); | ||
const result = await dialog; | ||
if(result.button.accept){ | ||
let files = result.value; | ||
} | ||
And for a folder. | ||
|
||
.. code:: typescript | ||
const dialog = FileDialog.getExistingDirectory({ | ||
manager // IDocumentManager | ||
}); | ||
const result = await dialog; | ||
if(result.button.accept){ | ||
let folders = result.value; | ||
} | ||
.. note:: The document manager can be obtained in a plugin by requesting | ||
``IFileBrowserFactory`` service. The manager will be accessed through | ||
``factory.defaultBrowser.model.manager``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters