Skip to content

Commit

Permalink
Merge pull request #179 from mwcraig/updates-for-8
Browse files Browse the repository at this point in the history
A collection of minor updates for 2022
  • Loading branch information
mwcraig authored Jun 17, 2022
2 parents 2cb282e + ad6ecd5 commit 1bbbf79
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 72 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# The Jupyter Widget Ecosystem

## Tutorial, SciPy 2021
## Tutorial, SciPy 2022

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

# Installation

### Installation instructions last updated 2021-06-07
**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.

The code in the tutorial has been written using Python 3; many of the dependencies may not be available for Python 2.7.
Either way, we will include some of the new features of ipywidgets 8 in the tutorial.

### Installation instructions last updated 2022-06-17

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).

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

## conda installation instructions

The steps below will get you a working environment.
The steps below will get you a working environment.

```bash
conda env create -f environment.yml

conda activate widgets-tutorial-2021
conda activate widgets-tutorial-2022

# Create a kernel for this environment
ipython kernel install --name widgets-tutorial --display-name widgets-tutorial --sys-prefix
Expand Down
32 changes: 16 additions & 16 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: widgets-tutorial-2021
name: widgets-tutorial-2022
channels:
- conda-forge
dependencies:
- bqplot=0.12.29
- ipycanvas=0.8.2
- ipycytoscape=1.2.2
- ipydatagrid=1.0.7
- bqplot=0.12.33
- branca=0.5.0
- ipycanvas=0.12.0
- ipycytoscape=1.3.3
- ipydatagrid=1.1.12
- ipyevents=2.0.1
- ipygany=0.5.0
- ipyleaflet=0.14.0
- ipympl=0.7.0
- ipyleaflet=0.16.0
- ipympl=0.9.1
- ipytree=0.2.1
- ipyvolume=0.6.0a8
- ipyvuetify=1.7.0
- ipywidgets=7.6
- jupyterlab=3
- ipyvuetify=1.8.2
- ipywidgets=7.7.0
- jupyterlab=3.4
- numpy
- pandas
- pip
- python=3.8
- python=3.9
- pythreejs=2.3.0
- pyvista=0.31.3
- pyvista=0.34.0
- requests
- scikit-image
- scipy
- sidecar=0.5.1
- voila=0.2.10
- voila-vuetify=0.5.2
- voila-material=0.4.0
- vtk=8.2.0
- voila=0.3.5
- vtk=9.1.0
2 changes: 1 addition & 1 deletion install_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
success = all(import_result.values())

# List compatible versions for each package
version_check_packages = {'ipywidgets': ['7.6'],
version_check_packages = {'ipywidgets': ['7.7'],
'jupyterlab': ['3'],
}

Expand Down
16 changes: 8 additions & 8 deletions notebooks/02.Interact/02.01-OPTIONAL-More-About-Interact.ipynb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"import ipywidgets as widgets"
"<!--NAVIGATION-->\n",
"< [Widgets without writing widgets: interact](02.00-Using-Interact.ipynb) | [Contents](00.00-index.ipynb) | [Simple Widget Introduction](03.00-Widget_Basics.ipynb) >"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"<!--NAVIGATION-->\n",
"< [Widgets without writing widgets: interact](02.00-Using-Interact.ipynb) | [Contents](00.00-index.ipynb) | [Simple Widget Introduction](03.00-Widget_Basics.ipynb) >"
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"import ipywidgets as widgets"
]
},
{
Expand Down
34 changes: 21 additions & 13 deletions notebooks/04.WidgetList/widget_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ def organized_widgets(organize_by='ui'):
'Valid options are: {valid_organizations}')

all_wids = inspect.getmembers(widgets)
# for a in all_wids:
# name = a[0]
# arf = a[1]
# if (not name.startswith('_') and
# name[0] in string.ascii_uppercase and
# issubclass(arf, widgets.DOMWidget)):
# print('woot')

widget_dict = {name: wid for name, wid in all_wids
if not name.startswith('_') and
name[0] in string.ascii_uppercase and
Expand Down Expand Up @@ -131,8 +125,15 @@ def fill_container(widget, name):

# Set tab or accordion names
if name == "accordion" or name == "tab":
for i in range(len(widget.children)):
widget.set_title(i, '{} {}'.format(name, i))
titles = [f'{name} {idx}' for idx, _ in enumerate(widget.children)]
try:
# Retrieve the titles attribute to see if it exists
widget.titles
except AttributeError:
for idx, title in enumerate(titles):
widget.set_title(idx, title)
else:
widget.titles = titles

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

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

tabs.children = kids

for i, title in enumerate(titles):
nice = title.replace('_', ' ')
tabs.set_title(i, nice.title())
try:
# Try to access the titles attribute to see if it exists
tabs.titles
except AttributeError:
# We must be using ipywidgets 7, so set_titles
for i, title in enumerate(titles):
nice = title.replace('_', ' ')
tabs.set_title(i, nice.title())
else:
# We have ipywidgets 8
tabs.titles = titles

return tabs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -29,6 +20,15 @@
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -52,7 +52,7 @@
},
"outputs": [],
"source": [
"helpful_title = 0 # Replace with some that displays \"Generated password is:\"\n",
"helpful_title = 0 # Replace with something that displays \"Generated password is:\"\n",
"password_text = 0 # Replace with something that displays \"No password set\"\n",
"password_length = 0 # Replace with slider\n"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -26,6 +17,15 @@
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"import traitlets"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -36,6 +26,16 @@
"+ one way to link those two classes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"import traitlets"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 1bbbf79

Please sign in to comment.