Widgets
Add a new Widget element to the main window.
In this example you will learn how to add a new tab to JupyterLab.
Visible elements such as tabs and notebooks are represented by widgets in the Lumino library that is the basis of the JupyterLab application.
It is the fundamental brick of any visual component in the JupyterLab interface.
ATP 定制服务端发起训练插件
A Basic Tab
The base widget class can be imported with:
// src/index.ts#L8-L8
import { Widget } from '@lumino/widgets';
It requires to add the library as package dependency:
jlpm add @lumino/widgets
A Widget can be added to the main area through the JupyterLab Shell.
Inside of the activate function, you can obtain it through the shell attribute
of the app object:
// src/index.ts#L19-L19
const { commands, shell } = app;
Then the widget can be inserted by calling the add method, like in the command defined
in this example:
// src/index.ts#L25-L28
execute: () => {
const widget = new ExampleWidget();
shell.add(widget, 'main');
}
The custom widget ExampleWidget is inherited from the base class Widget.
In this case, no specific behavior is defined for the widget. Only some properties are set:
addClass: Add a CSS class to allow widget stylingid: id of the widget's DOM node - it is mandatory to be set to be included in JupyterLabtitle.label: The widget tab titletitle.closable: Allow the widget tab to be closed
// src/index.ts#L36-L44
class ExampleWidget extends Widget {
constructor() {
super();
this.addClass('jp-example-view');
this.id = 'iflytek-atp-widget';
this.title.label = 'Widget Example View';
this.title.closable = true;
}
}
You can associate style properties to the custom CSS class in the file
style/base.css:
.jp-example-view {
background-color: aliceblue;
}
Where to Go Next
This example uses a command to display the widget. Have a look a the commands example for more information about it.
The widget created in this example is simple. You will find more advanced widgets in the following examples:
- Widget showing a Datagrid
- Widget integrating React components
- Widget interacting with a Kernel
- Extending document widget (like the notebook panel) with a new Toolbar Button
Metadata
Release files for jupyterlab_atp_extension 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| jupyterlab_atp_extension-1.0.3.tar.gz | 381.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jupyterlab_atp_extension-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 427.1 kB
Release files / jupyterlab_atp_extension-1.0.3.tar.gz
| Download URL | jupyterlab_atp_extension-1.0.3.tar.gz |
|---|---|
| Size | 381.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a0c44ca59a2fcd62412b9378219003ed887e3a7d23e71a03f2e823935397a86
|
|
BLAKE2b-256 checksum How to use checksums |
4301ac5e223d4850a3a87f08e87a6c941ce5f52fa8a1298ba7e42fad0c67953b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.1
|
Release files / jupyterlab_atp_extension-1.0.3-py3-none-any.whl
| Download URL | jupyterlab_atp_extension-1.0.3-py3-none-any.whl |
|---|---|
| Size | 45.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4ca2c582b552cd3080c23051bcba62baf8109dbf941b2da15936f2ab830d48e
|
|
BLAKE2b-256 checksum How to use checksums |
7f157120e61eee63975c326d9bde365f761785701d99e99a8d0cc0f2a8e2d8f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.1
|
Security for jupyterlab_atp_extension 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.