You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example shows how to clear all celloutputs at once by clicking on the button.
4
4
5
-
A JupyterLab extension for clearing all cells output at once.
5
+

6
6
7
+
<!-- A JupyterLab extension for clearing all cells output at once. -->
7
8
9
+
To use it first we need to import the packages
10
+
```
11
+
import { ToolbarButton } from '@jupyterlab/apputils';
12
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
13
+
import { NotebookActions, NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
14
+
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
15
+
import { IDisposable, DisposableDelegate } from '@lumino/disposable';
16
+
```
17
+
18
+
Firstly we have to register the plugin information. In this we have to pass a activate **function** & the plugin **id**.
19
+
20
+
```
21
+
const plugin: JupyterFrontEndPlugin<void> = {
22
+
activate,
23
+
id: 'clear-cell-outputs:buttonPlugin',
24
+
autoStart: true
25
+
};
26
+
```
27
+
Now creating a notebook widget extension that adds a button to the toolbar. For more info [IWidgetExtension](https://jupyterlab.readthedocs.io/en/latest/api/interfaces/docregistry.documentregistry.iwidgetextension.html)
28
+
29
+
```
30
+
export
31
+
class ButtonExtension implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> {
app.docRegistry.addWidgetExtension('Notebook', new ButtonExtension());
57
+
};
58
+
```
8
59
9
60
## Requirements
10
61
@@ -26,51 +77,3 @@ To remove the extension, execute:
26
77
pip uninstall clear_cell_outputs
27
78
```
28
79
29
-
30
-
## Contributing
31
-
32
-
### Development install
33
-
34
-
Note: You will need NodeJS to build the extension package.
35
-
36
-
The `jlpm` command is JupyterLab's pinned version of
37
-
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
38
-
`yarn` or `npm` in lieu of `jlpm` below.
39
-
40
-
```bash
41
-
# Clone the repo to your local environment
42
-
# Change directory to the clear_cell_outputs directory
43
-
# Install package in development mode
44
-
pip install -e .
45
-
# Link your development version of the extension with JupyterLab
46
-
jupyter labextension develop . --overwrite
47
-
# Rebuild extension Typescript source after making changes
48
-
jlpm run build
49
-
```
50
-
51
-
You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
52
-
53
-
```bash
54
-
# Watch the source directory in one terminal, automatically rebuilding when needed
55
-
jlpm run watch
56
-
# Run JupyterLab in another terminal
57
-
jupyter lab
58
-
```
59
-
60
-
With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
61
-
62
-
By default, the `jlpm run build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
63
-
64
-
```bash
65
-
jupyter lab build --minimize=False
66
-
```
67
-
68
-
### Development uninstall
69
-
70
-
```bash
71
-
pip uninstall clear_cell_outputs
72
-
```
73
-
74
-
In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
75
-
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
76
-
folder is located. Then you can remove the symlink named `clear-cell-outputs` within that folder.
0 commit comments