Skip to content

Commit 1bbbf79

Browse files
authored
Merge pull request #179 from mwcraig/updates-for-8
A collection of minor updates for 2022
2 parents 2cb282e + ad6ecd5 commit 1bbbf79

8 files changed

+82
-72
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# The Jupyter Widget Ecosystem
22

3-
## Tutorial, SciPy 2021
3+
## Tutorial, SciPy 2022
44

55
# https://github.com/jupyter-widgets/tutorial
66

77
# Installation
88

9-
### Installation instructions last updated 2021-06-07
9+
**NOTE**: These installation instructions install `ipywidgets` version 7.7. We anticipate that ipywidgets 8 will be released before the tutorial. If it, and all of the packages that we use that are dependent on `ipywidgets` have releases before the tutorial we will also provide ipywidgets 8 installation instructions.
1010

11-
The code in the tutorial has been written using Python 3; many of the dependencies may not be available for Python 2.7.
11+
Either way, we will include some of the new features of ipywidgets 8 in the tutorial.
12+
13+
### Installation instructions last updated 2022-06-17
1214

1315
We **strongly recommend** using the conda Python distribution. You can install either [miniconda](https://conda.io/miniconda.html) (much smaller, only essential packages) or the full [anaconda distribution](https://www.continuum.io/downloads) (very extensive, but very, very large).
1416

@@ -24,12 +26,12 @@ You can do this with either `git clone https://github.com/jupyter-widgets/tutori
2426

2527
## conda installation instructions
2628

27-
The steps below will get you a working environment.
29+
The steps below will get you a working environment.
2830

2931
```bash
3032
conda env create -f environment.yml
3133

32-
conda activate widgets-tutorial-2021
34+
conda activate widgets-tutorial-2022
3335

3436
# Create a kernel for this environment
3537
ipython kernel install --name widgets-tutorial --display-name widgets-tutorial --sys-prefix

environment.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
name: widgets-tutorial-2021
1+
name: widgets-tutorial-2022
22
channels:
33
- conda-forge
44
dependencies:
5-
- bqplot=0.12.29
6-
- ipycanvas=0.8.2
7-
- ipycytoscape=1.2.2
8-
- ipydatagrid=1.0.7
5+
- bqplot=0.12.33
6+
- branca=0.5.0
7+
- ipycanvas=0.12.0
8+
- ipycytoscape=1.3.3
9+
- ipydatagrid=1.1.12
10+
- ipyevents=2.0.1
911
- ipygany=0.5.0
10-
- ipyleaflet=0.14.0
11-
- ipympl=0.7.0
12+
- ipyleaflet=0.16.0
13+
- ipympl=0.9.1
1214
- ipytree=0.2.1
1315
- ipyvolume=0.6.0a8
14-
- ipyvuetify=1.7.0
15-
- ipywidgets=7.6
16-
- jupyterlab=3
16+
- ipyvuetify=1.8.2
17+
- ipywidgets=7.7.0
18+
- jupyterlab=3.4
1719
- numpy
1820
- pandas
1921
- pip
20-
- python=3.8
22+
- python=3.9
2123
- pythreejs=2.3.0
22-
- pyvista=0.31.3
24+
- pyvista=0.34.0
2325
- requests
2426
- scikit-image
2527
- scipy
2628
- sidecar=0.5.1
27-
- voila=0.2.10
28-
- voila-vuetify=0.5.2
29-
- voila-material=0.4.0
30-
- vtk=8.2.0
29+
- voila=0.3.5
30+
- vtk=9.1.0

install_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
success = all(import_result.values())
4141

4242
# List compatible versions for each package
43-
version_check_packages = {'ipywidgets': ['7.6'],
43+
version_check_packages = {'ipywidgets': ['7.7'],
4444
'jupyterlab': ['3'],
4545
}
4646

notebooks/02.Interact/02.01-OPTIONAL-More-About-Interact.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"cells": [
33
{
4-
"cell_type": "code",
5-
"execution_count": null,
4+
"cell_type": "markdown",
65
"metadata": {},
7-
"outputs": [],
86
"source": [
9-
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
10-
"import ipywidgets as widgets"
7+
"<!--NAVIGATION-->\n",
8+
"< [Widgets without writing widgets: interact](02.00-Using-Interact.ipynb) | [Contents](00.00-index.ipynb) | [Simple Widget Introduction](03.00-Widget_Basics.ipynb) >"
119
]
1210
},
1311
{
14-
"cell_type": "markdown",
12+
"cell_type": "code",
13+
"execution_count": null,
1514
"metadata": {},
15+
"outputs": [],
1616
"source": [
17-
"<!--NAVIGATION-->\n",
18-
"< [Widgets without writing widgets: interact](02.00-Using-Interact.ipynb) | [Contents](00.00-index.ipynb) | [Simple Widget Introduction](03.00-Widget_Basics.ipynb) >"
17+
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
18+
"import ipywidgets as widgets"
1919
]
2020
},
2121
{

notebooks/04.WidgetList/widget_org.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ def organized_widgets(organize_by='ui'):
4848
'Valid options are: {valid_organizations}')
4949

5050
all_wids = inspect.getmembers(widgets)
51-
# for a in all_wids:
52-
# name = a[0]
53-
# arf = a[1]
54-
# if (not name.startswith('_') and
55-
# name[0] in string.ascii_uppercase and
56-
# issubclass(arf, widgets.DOMWidget)):
57-
# print('woot')
51+
5852
widget_dict = {name: wid for name, wid in all_wids
5953
if not name.startswith('_') and
6054
name[0] in string.ascii_uppercase and
@@ -131,8 +125,15 @@ def fill_container(widget, name):
131125

132126
# Set tab or accordion names
133127
if name == "accordion" or name == "tab":
134-
for i in range(len(widget.children)):
135-
widget.set_title(i, '{} {}'.format(name, i))
128+
titles = [f'{name} {idx}' for idx, _ in enumerate(widget.children)]
129+
try:
130+
# Retrieve the titles attribute to see if it exists
131+
widget.titles
132+
except AttributeError:
133+
for idx, title in enumerate(titles):
134+
widget.set_title(idx, title)
135+
else:
136+
widget.titles = titles
136137

137138
# Start with all the accordions closed
138139
if name == "accordion":
@@ -219,7 +220,6 @@ def box_maker(name, widget, group):
219220
return b
220221

221222
for group, group_widgets in groups.items():
222-
# print(group)
223223
titles.append(group)
224224
col_spec = f"repeat({columns}, minmax({min_width_single_widget}px, 1fr)"
225225
layout = widgets.Layout(grid_template_columns=col_spec,
@@ -230,8 +230,16 @@ def box_maker(name, widget, group):
230230

231231
tabs.children = kids
232232

233-
for i, title in enumerate(titles):
234-
nice = title.replace('_', ' ')
235-
tabs.set_title(i, nice.title())
233+
try:
234+
# Try to access the titles attribute to see if it exists
235+
tabs.titles
236+
except AttributeError:
237+
# We must be using ipywidgets 7, so set_titles
238+
for i, title in enumerate(titles):
239+
nice = title.replace('_', ' ')
240+
tabs.set_title(i, nice.title())
241+
else:
242+
# We have ipywidgets 8
243+
tabs.titles = titles
236244

237245
return tabs

notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {},
7-
"outputs": [],
8-
"source": [
9-
"import ipywidgets as widgets"
10-
]
11-
},
123
{
134
"cell_type": "markdown",
145
"metadata": {},
@@ -29,6 +20,15 @@
2920
"This notebook illustrates how to connect the function that calculates the password to the length slider using `observe` but mixes together the code to calculate the password and the code to handle the events generated by the interface"
3021
]
3122
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"import ipywidgets as widgets"
30+
]
31+
},
3232
{
3333
"cell_type": "markdown",
3434
"metadata": {},
@@ -52,7 +52,7 @@
5252
},
5353
"outputs": [],
5454
"source": [
55-
"helpful_title = 0 # Replace with some that displays \"Generated password is:\"\n",
55+
"helpful_title = 0 # Replace with something that displays \"Generated password is:\"\n",
5656
"password_text = 0 # Replace with something that displays \"No password set\"\n",
5757
"password_length = 0 # Replace with slider\n"
5858
]

notebooks/05.Events/05.03-OPTIONAL-Widget_Events_2_--_Separating_Concerns.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {},
7-
"outputs": [],
8-
"source": [
9-
"import ipywidgets as widgets"
10-
]
11-
},
123
{
134
"cell_type": "markdown",
145
"metadata": {},
@@ -26,6 +17,15 @@
2617
"A key principle in designing a graphical user interface is to separate the logic of an application from the graphical widgets the user sees. For example, in the super-simple password generator widget, the basic logic is to construct a sequence of random letters given the length. Let's isolate that logic in a function, without any widgets. This function takes a password length and returns a generated password string."
2718
]
2819
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": null,
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"import ipywidgets as widgets"
27+
]
28+
},
2929
{
3030
"cell_type": "code",
3131
"execution_count": null,

notebooks/05.Events/05.04-OPTIONAL-Widget_Events_2--Separating_concerns,_object_oriented.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {},
7-
"outputs": [],
8-
"source": [
9-
"import ipywidgets as widgets\n",
10-
"import traitlets"
11-
]
12-
},
133
{
144
"cell_type": "markdown",
155
"metadata": {},
@@ -36,6 +26,16 @@
3626
"+ one way to link those two classes."
3727
]
3828
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"metadata": {},
33+
"outputs": [],
34+
"source": [
35+
"import ipywidgets as widgets\n",
36+
"import traitlets"
37+
]
38+
},
3939
{
4040
"cell_type": "markdown",
4141
"metadata": {},

0 commit comments

Comments
 (0)