Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A collection of minor updates for 2022 #179

Merged
merged 6 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to make a new release of ipympl if we switch to ipywidgets 8. The current release has a gate on ipywidgets<8.
I started work on that here: matplotlib/ipympl#461 but stalled out bc I couldn't get the tests all passing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these will need new releases for ipywidgets 8 -- the pins should make sure that no one gets an 8-only package.

One reason for setting the goal of presenting in 8 is to help work through the remaining issue.

- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last in the 0.2.x series is 16

Suggested change
- voila=0.2.19
- voila=0.2.16

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks -- ended up changing it to 0.3.5 and dropping voila-vuetify and voila-material

- voila-vuetify=0.5.2
- voila-material=0.4.0
- vtk=8.2.0
- vtk=9.1.0
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