From 0c1a99250d12d863878150c1e6625062cf88fbde Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Mon, 13 Jun 2022 13:45:54 -0500 Subject: [PATCH 1/6] Update for change in setting titles on tab/accordion --- notebooks/04.WidgetList/widget_org.py | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/notebooks/04.WidgetList/widget_org.py b/notebooks/04.WidgetList/widget_org.py index d24afbf6..80ba3d80 100644 --- a/notebooks/04.WidgetList/widget_org.py +++ b/notebooks/04.WidgetList/widget_org.py @@ -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 @@ -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": @@ -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, @@ -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 From db4976e936a418abe832643695a1aa2a90ba0a03 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Thu, 16 Jun 2022 10:47:14 -0500 Subject: [PATCH 2/6] Fix a typo --- ...L-Widget_Events_2_--_bad_password_generator,_version_1.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb b/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb index 8441decc..5a2f9bf2 100644 --- a/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb +++ b/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb @@ -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" ] From 9d9ce60443985f1d8760ea8e964fe1f948592d46 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Thu, 16 Jun 2022 11:48:37 -0500 Subject: [PATCH 3/6] Move import cells to be more visible --- .../02.01-OPTIONAL-More-About-Interact.ipynb | 16 +++++++-------- ...--_bad_password_generator,_version_1.ipynb | 18 ++++++++--------- ...dget_Events_2_--_Separating_Concerns.ipynb | 18 ++++++++--------- ...Separating_concerns,_object_oriented.ipynb | 20 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/notebooks/02.Interact/02.01-OPTIONAL-More-About-Interact.ipynb b/notebooks/02.Interact/02.01-OPTIONAL-More-About-Interact.ipynb index 14a69ff9..d9d3bd43 100644 --- a/notebooks/02.Interact/02.01-OPTIONAL-More-About-Interact.ipynb +++ b/notebooks/02.Interact/02.01-OPTIONAL-More-About-Interact.ipynb @@ -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" + "\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": [ - "\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" ] }, { diff --git a/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb b/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb index 5a2f9bf2..c8ce3d01 100644 --- a/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb +++ b/notebooks/05.Events/05.02-OPTIONAL-Widget_Events_2_--_bad_password_generator,_version_1.ipynb @@ -1,14 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import ipywidgets as widgets" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -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": {}, diff --git a/notebooks/05.Events/05.03-OPTIONAL-Widget_Events_2_--_Separating_Concerns.ipynb b/notebooks/05.Events/05.03-OPTIONAL-Widget_Events_2_--_Separating_Concerns.ipynb index 1b9883c3..70f7b4d7 100644 --- a/notebooks/05.Events/05.03-OPTIONAL-Widget_Events_2_--_Separating_Concerns.ipynb +++ b/notebooks/05.Events/05.03-OPTIONAL-Widget_Events_2_--_Separating_Concerns.ipynb @@ -1,14 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import ipywidgets as widgets" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -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, diff --git a/notebooks/05.Events/05.04-OPTIONAL-Widget_Events_2--Separating_concerns,_object_oriented.ipynb b/notebooks/05.Events/05.04-OPTIONAL-Widget_Events_2--Separating_concerns,_object_oriented.ipynb index 0455ba8c..94efbf85 100644 --- a/notebooks/05.Events/05.04-OPTIONAL-Widget_Events_2--Separating_concerns,_object_oriented.ipynb +++ b/notebooks/05.Events/05.04-OPTIONAL-Widget_Events_2--Separating_concerns,_object_oriented.ipynb @@ -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": {}, @@ -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": {}, From c94508276097464e2e21fa8a27266b99e0087a8f Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Thu, 16 Jun 2022 11:57:13 -0500 Subject: [PATCH 4/6] Update environment file for 2022, ipywidgets=7 --- environment.yml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/environment.yml b/environment.yml index 8205a119..e1e77d63 100644 --- a/environment.yml +++ b/environment.yml @@ -1,30 +1,32 @@ -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=0.2.19 - voila-vuetify=0.5.2 - voila-material=0.4.0 - - vtk=8.2.0 + - vtk=9.1.0 From eaafa81eb5c4b0a51dfa9ea3d1c93ddbff2188dc Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Fri, 17 Jun 2022 14:29:13 -0500 Subject: [PATCH 5/6] Update requirements and install check script --- environment.yml | 4 +--- install_check.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/environment.yml b/environment.yml index e1e77d63..a4e02a93 100644 --- a/environment.yml +++ b/environment.yml @@ -26,7 +26,5 @@ dependencies: - scikit-image - scipy - sidecar=0.5.1 - - voila=0.2.19 - - voila-vuetify=0.5.2 - - voila-material=0.4.0 + - voila=0.3.5 - vtk=9.1.0 diff --git a/install_check.py b/install_check.py index 4906e0b6..29e2440d 100644 --- a/install_check.py +++ b/install_check.py @@ -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'], } From ad6ecd5775f7020b649311b775f75743a8bb7455 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Fri, 17 Jun 2022 14:29:44 -0500 Subject: [PATCH 6/6] Update README --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b7607fed..7ee77708 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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