Skip to content

Commit 11201ef

Browse files
authored
Merge pull request #2 from osscar-org/develop
Support for JLab2.1 with new features
2 parents df31294 + ff77176 commit 11201ef

File tree

11 files changed

+294
-147
lines changed

11 files changed

+294
-147
lines changed

.github/workflows/build.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v1
1515
- name: Install node
1616
uses: actions/setup-node@v1
1717
with:
18-
node-version: '10.x'
18+
node-version: '13.x'
1919
- name: Install Python
2020
uses: actions/setup-python@v1
2121
with:
22-
python-version: '3.7'
22+
python-version: '3.8'
2323
architecture: 'x64'
2424
- name: Install dependencies
25-
run: python -m pip install jupyterlab==1.2.6
25+
run: |
26+
python -m pip install jupyterlab==2.1.1
27+
python -m pip install ipywidgets
2628
- name: Build the extension
2729
run: |
2830
jlpm && jlpm run build

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# widget-periodictable
22

3-
![Build](https://github.com/osscar-org/widget-periodictable/workflows/Build/badge.svg)
3+
![Build](https://github.com/osscar-org/widget-periodictable/workflows/Build/badge.svg?branch=develop)
44

55
A jupyter widget to select chemical elements from the periodic table. This is a update version of the
66
widget from:
@@ -14,7 +14,7 @@ https://github.com/aiidalab/aiidalab-widget-periodictable
1414

1515
## Usage and try it on Binder
1616

17-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/osscar-org/widget-periodictable/master?urlpath=%2Flab%2Ftree%2Fexamples%2Fintroduction.ipynb)
17+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/osscar-org/widget-periodictable/develop?urlpath=%2Flab%2Ftree%2Fexamples%2Fintroduction.ipynb)
1818

1919
## Installation
2020

@@ -37,6 +37,16 @@ the nbextension:
3737
```bash
3838
jupyter nbextension enable --py [--sys-prefix|--user|--system] widget_periodictable
3939
```
40+
41+
## Selection and disable
42+
43+
By clicking on the elements, one can select and disable the elements. The selected elements can be divided into different states with custom colors.
44+
One can obtain the element list by state.
45+
46+
```bash
47+
PTable.get_elements_by_state(1)
48+
```
49+
4050
# Acknowlegements
4151

4252
We acknowledge support from:

examples/introduction.ipynb

+97-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -19,12 +19,27 @@
1919
},
2020
{
2121
"cell_type": "code",
22-
"execution_count": null,
22+
"execution_count": 2,
2323
"metadata": {},
24-
"outputs": [],
24+
"outputs": [
25+
{
26+
"data": {
27+
"application/vnd.jupyter.widget-view+json": {
28+
"model_id": "312dc9bc4c7645ba8711de89900c888a",
29+
"version_major": 2,
30+
"version_minor": 0
31+
},
32+
"text/plain": [
33+
"PTableWidget(noselect_color='blue', selected_colors=['red', 'green', 'yellow'], states=3)"
34+
]
35+
},
36+
"metadata": {},
37+
"output_type": "display_data"
38+
}
39+
],
2540
"source": [
2641
"# Show the widget\n",
27-
"widget = PTableWidget()\n",
42+
"widget = PTableWidget(states = 3, selected_colors = ['red', 'green', 'yellow'], noselect_color='blue')\n",
2843
"widget"
2944
]
3045
},
@@ -44,9 +59,24 @@
4459
},
4560
{
4661
"cell_type": "code",
47-
"execution_count": null,
62+
"execution_count": 3,
4863
"metadata": {},
49-
"outputs": [],
64+
"outputs": [
65+
{
66+
"data": {
67+
"application/vnd.jupyter.widget-view+json": {
68+
"model_id": "9f716d75f43f46e0913e2b4e19f04f04",
69+
"version_major": 2,
70+
"version_minor": 0
71+
},
72+
"text/plain": [
73+
"VBox(children=(Button(button_style='success', description='Get the currently selected values', layout=Layout(w…"
74+
]
75+
},
76+
"metadata": {},
77+
"output_type": "display_data"
78+
}
79+
],
5080
"source": [
5181
"output = widgets.Output()\n",
5282
"\n",
@@ -76,9 +106,24 @@
76106
},
77107
{
78108
"cell_type": "code",
79-
"execution_count": null,
109+
"execution_count": 4,
80110
"metadata": {},
81-
"outputs": [],
111+
"outputs": [
112+
{
113+
"data": {
114+
"application/vnd.jupyter.widget-view+json": {
115+
"model_id": "ba9d09402e0c43fe95a68fcb72561881",
116+
"version_major": 2,
117+
"version_minor": 0
118+
},
119+
"text/plain": [
120+
"Checkbox(value=False, description='Disable oxygen')"
121+
]
122+
},
123+
"metadata": {},
124+
"output_type": "display_data"
125+
}
126+
],
82127
"source": [
83128
"toggle_disabled = widgets.Checkbox(\n",
84129
" value=\"O\" in widget.disabled_elements,\n",
@@ -114,9 +159,24 @@
114159
},
115160
{
116161
"cell_type": "code",
117-
"execution_count": null,
162+
"execution_count": 5,
118163
"metadata": {},
119-
"outputs": [],
164+
"outputs": [
165+
{
166+
"data": {
167+
"application/vnd.jupyter.widget-view+json": {
168+
"model_id": "24001f1755fe492c97818b9fb70cf517",
169+
"version_major": 2,
170+
"version_minor": 0
171+
},
172+
"text/plain": [
173+
"Button(button_style='success', description='Select only Li and H (from python)', layout=Layout(width='300px'),…"
174+
]
175+
},
176+
"metadata": {},
177+
"output_type": "display_data"
178+
}
179+
],
120180
"source": [
121181
"def on_set_from_ptyhon(event):\n",
122182
" # NOTE! If you put an element which does not exist, it will stay forever in the list, but it's ignored\n",
@@ -141,9 +201,24 @@
141201
},
142202
{
143203
"cell_type": "code",
144-
"execution_count": null,
204+
"execution_count": 6,
145205
"metadata": {},
146-
"outputs": [],
206+
"outputs": [
207+
{
208+
"data": {
209+
"application/vnd.jupyter.widget-view+json": {
210+
"model_id": "c99467dc0c284c1b9e4bb718730c8366",
211+
"version_major": 2,
212+
"version_minor": 0
213+
},
214+
"text/plain": [
215+
"Button(button_style='success', description='Make noble gases bold', layout=Layout(width='300px'), style=Button…"
216+
]
217+
},
218+
"metadata": {},
219+
"output_type": "display_data"
220+
}
221+
],
147222
"source": [
148223
"def get_noble_gases_state():\n",
149224
" label_deactivate = \"Make noble gases bold\"\n",
@@ -188,6 +263,15 @@
188263
"button_noble.on_click(on_toggle_noble_gases)\n",
189264
"button_noble"
190265
]
266+
},
267+
{
268+
"cell_type": "markdown",
269+
"metadata": {},
270+
"source": [
271+
"This work has been done with the support of the EPFL Open Science Fund [OSSCAR](http://www.osscar.org).\n",
272+
"\n",
273+
"<img src=\"http://www.osscar.org/wp-content/uploads/2019/03/OSSCAR-logo.png\" style=\"height:40px; width: 200px\"/>"
274+
]
191275
}
192276
],
193277
"metadata": {
@@ -206,7 +290,7 @@
206290
"name": "python",
207291
"nbconvert_exporter": "python",
208292
"pygments_lexer": "ipython3",
209-
"version": "3.8.1"
293+
"version": "3.8.2"
210294
}
211295
},
212296
"nbformat": 4,

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "widget-periodictable",
3-
"version": "0.3.0",
3+
"version": "1.1.0",
44
"description": "A jupyter widget to select chemical elements from the periodic table.",
55
"keywords": [
66
"jupyter",
@@ -49,7 +49,7 @@
4949
"watch:nbextension": "webpack --watch"
5050
},
5151
"dependencies": {
52-
"@jupyter-widgets/base": "^1.1.10 || ^2"
52+
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3"
5353
},
5454
"devDependencies": {
5555
"@phosphor/application": "^1.6.0",
@@ -75,7 +75,7 @@
7575
"source-map-loader": "^0.2.4",
7676
"style-loader": "^1.0.0",
7777
"ts-loader": "^5.2.1",
78-
"typescript": "~3.1.2",
78+
"typescript": "~3.8",
7979
"webpack": "^4.20.2",
8080
"webpack-cli": "^3.1.2"
8181
},

periodictable.png

19.3 KB
Loading

src/plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const examplePlugin: IPlugin<Application<Widget>, void> = {
2929
requires: [IJupyterWidgetRegistry],
3030
activate: activateWidgetExtension,
3131
autoStart: true
32-
};
32+
} as unknown as IPlugin<Application<Widget>, void>;
3333

3434
export default examplePlugin;
3535

0 commit comments

Comments
 (0)