Skip to content

Commit b6a01b0

Browse files
author
Alan Fleming
committed
Merge branch 'main' of https://github.com/jupyter-widgets/ipywidgets into per-kernel-widget-manager
2 parents 23d9b2b + b24fa6b commit b6a01b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+844
-168
lines changed

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ipyleaflet
66
jupyter-client
77
jupyter-packaging
88
jupyterlab >=4
9-
jupyterlite-core >=0.3.0<0.4.0
10-
jupyterlite-pyodide-kernel >=0.3.0<0.4.0
9+
jupyterlite-core >=0.3.0,<0.4.0
10+
jupyterlite-pyodide-kernel >=0.3.0,<0.4.0
1111
matplotlib
1212
myst-nb >=0.17,<0.18
1313
numpy

docs/source/dev_install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The core Jupyter Widgets packages are developed in the
77

88
To install ipywidgets from git, you will need:
99

10-
- [yarn](https://yarnpkg.com/) package manager ** version 1.2.1 or later **
10+
- [yarn](https://yarnpkg.com/) package manager ** version 3.0 or later **
1111

1212
- the latest [Jupyter Notebook development release](https://github.com/jupyter/notebook/releases)
1313

docs/source/examples/Image Processing.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"cell_type": "code",
1919
"execution_count": null,
2020
"metadata": {
21-
"tags": ["remove-cell"]
21+
"tags": [
22+
"remove-cell"
23+
]
2224
},
2325
"outputs": [],
2426
"source": [
@@ -39,6 +41,7 @@
3941
"from IPython.display import Image\n",
4042
"from ipywidgets import interact, interactive, fixed\n",
4143
"import matplotlib as mpl\n",
44+
"import matplotlib.pyplot as plt\n",
4245
"from skimage import data, filters, io, img_as_float\n",
4346
"import numpy as np"
4447
]
@@ -84,7 +87,7 @@
8487
" # Don't let matplotlib autoscale the color range so we can control overall luminosity\n",
8588
" vmax = 255 if arr.dtype == 'uint8' else 1.0\n",
8689
" with BytesIO() as buffer:\n",
87-
" mpl.image.imsave(buffer, arr, format=format, cmap=cmap, vmin=0, vmax=vmax)\n",
90+
" plt.imsave(buffer, arr, format=format, cmap=cmap, vmin=0, vmax=vmax)\n",
8891
" out = buffer.getvalue()\n",
8992
" return Image(out)"
9093
]
@@ -230,9 +233,9 @@
230233
"name": "python",
231234
"nbconvert_exporter": "python",
232235
"pygments_lexer": "ipython3",
233-
"version": "3.10.5"
236+
"version": "3.11.4"
234237
}
235238
},
236239
"nbformat": 4,
237-
"nbformat_minor": 2
240+
"nbformat_minor": 4
238241
}

docs/source/examples/Output Widget.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@
354354
"```python\n",
355355
"import threading\n",
356356
"import time\n",
357+
"import itertools\n",
357358
"\n",
358359
"def run():\n",
359360
" for i in itertools.count(0):\n",

docs/source/examples/Using Interact.ipynb

Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"cell_type": "code",
1919
"execution_count": null,
2020
"metadata": {
21-
"tags": ["remove-cell"]
21+
"tags": [
22+
"remove-cell"
23+
]
2224
},
2325
"outputs": [],
2426
"source": [
@@ -353,6 +355,111 @@
353355
"interact(f, x=widgets.Combobox(options=[\"Chicago\", \"New York\", \"Washington\"], value=\"Chicago\"));"
354356
]
355357
},
358+
{
359+
"cell_type": "markdown",
360+
"metadata": {},
361+
"source": [
362+
"## Type Annotations"
363+
]
364+
},
365+
{
366+
"cell_type": "markdown",
367+
"metadata": {},
368+
"source": [
369+
"If the function that you are using with interact uses type annotations, `interact` may be able to use those to determine what UI components to use in the auto-generated UI. For example, given a function with an argument annotated with type `float`"
370+
]
371+
},
372+
{
373+
"cell_type": "code",
374+
"execution_count": null,
375+
"metadata": {},
376+
"outputs": [],
377+
"source": [
378+
"def f(x: float):\n",
379+
" return x"
380+
]
381+
},
382+
{
383+
"cell_type": "markdown",
384+
"metadata": {},
385+
"source": [
386+
"then `interact` will create a UI with a `FloatText` component without needing to be passed any values or abbreviations."
387+
]
388+
},
389+
{
390+
"cell_type": "code",
391+
"execution_count": null,
392+
"metadata": {},
393+
"outputs": [],
394+
"source": [
395+
"interact(f);"
396+
]
397+
},
398+
{
399+
"cell_type": "markdown",
400+
"metadata": {},
401+
"source": [
402+
"The following table gives an overview of different annotation types, and how they map to interactive controls:\n",
403+
"\n",
404+
"<table class=\"table table-condensed table-bordered\">\n",
405+
" <tr><td><strong>Type Annotation</strong></td><td><strong>Widget</strong></td></tr> \n",
406+
" <tr><td>`bool`</td><td>Checkbox</td></tr> \n",
407+
" <tr><td>`str`</td><td>Text</td></tr>\n",
408+
" <tr><td>`int`</td><td>IntText</td></tr>\n",
409+
" <tr><td>`float`</td><td>FloatText</td></tr>\n",
410+
" <tr><td>`Enum` subclasses</td><td>Dropdown</td></tr>\n",
411+
"</table>\n",
412+
"\n",
413+
"Other type annotations are ignored."
414+
]
415+
},
416+
{
417+
"cell_type": "markdown",
418+
"metadata": {},
419+
"source": [
420+
"If values or abbreviations are passed to the `interact` function, those will override any type annotations when determining what widgets to create."
421+
]
422+
},
423+
{
424+
"cell_type": "markdown",
425+
"metadata": {},
426+
"source": [
427+
"Parameters which are annotationed with an `Enum` subclass will have a dropdown created whose labels are the names of the enumeration and which pass the corresponding values to the function parameter."
428+
]
429+
},
430+
{
431+
"cell_type": "code",
432+
"execution_count": null,
433+
"metadata": {},
434+
"outputs": [],
435+
"source": [
436+
"from enum import Enum\n",
437+
"\n",
438+
"class Color(Enum):\n",
439+
" red = 0\n",
440+
" green = 1\n",
441+
" blue = 2\n",
442+
"\n",
443+
"def h(color: Color):\n",
444+
" return color"
445+
]
446+
},
447+
{
448+
"cell_type": "markdown",
449+
"metadata": {},
450+
"source": [
451+
"When `interact` is used with the function `h`, the Dropdown widget it creates will have options `\"red\"`, `\"green\"` and `\"blue\"` and the values passed to the function will be, correspondingly, `Color.red`, `Color.green` and `Color.blue`."
452+
]
453+
},
454+
{
455+
"cell_type": "code",
456+
"execution_count": null,
457+
"metadata": {},
458+
"outputs": [],
459+
"source": [
460+
"interact(h);"
461+
]
462+
},
356463
{
357464
"cell_type": "markdown",
358465
"metadata": {},
@@ -715,7 +822,7 @@
715822
},
716823
{
717824
"cell_type": "code",
718-
"execution_count": 1,
825+
"execution_count": null,
719826
"metadata": {},
720827
"outputs": [],
721828
"source": [
@@ -762,9 +869,9 @@
762869
"name": "python",
763870
"nbconvert_exporter": "python",
764871
"pygments_lexer": "ipython3",
765-
"version": "3.10.5"
872+
"version": "3.12.2"
766873
}
767874
},
768875
"nbformat": 4,
769-
"nbformat_minor": 2
876+
"nbformat_minor": 4
770877
}

docs/source/examples/Widget Custom.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"\n",
123123
"You also need to enable the widget frontend extension.\n",
124124
"\n",
125-
"If you are using JupyterLab 3.x:\n",
125+
"If you are using JupyterLab (version 3.x or above):\n",
126126
"\n",
127127
"\n",
128128
"```bash\n",

examples/web1/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jupyter-widgets/example-web1",
3-
"version": "8.0.10",
3+
"version": "8.0.12",
44
"private": true,
55
"description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.",
66
"license": "BSD-3-Clause",
@@ -16,9 +16,9 @@
1616
"test:firefox:headless": "npm run test:default -- --browsers=FirefoxHeadless"
1717
},
1818
"dependencies": {
19-
"@jupyter-widgets/base": "^6.0.8",
20-
"@jupyter-widgets/base-manager": "^1.0.9",
21-
"@jupyter-widgets/controls": "^5.0.9"
19+
"@jupyter-widgets/base": "^6.0.10",
20+
"@jupyter-widgets/base-manager": "^1.0.11",
21+
"@jupyter-widgets/controls": "^5.0.11"
2222
},
2323
"devDependencies": {
2424
"chai": "^4.0.0",

examples/web2/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jupyter-widgets/example-web2",
3-
"version": "8.0.10",
3+
"version": "8.0.12",
44
"private": true,
55
"description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.",
66
"license": "BSD-3-Clause",
@@ -13,9 +13,9 @@
1313
"test:default": "echo \"No test specified\""
1414
},
1515
"dependencies": {
16-
"@jupyter-widgets/base": "^6.0.8",
17-
"@jupyter-widgets/base-manager": "^1.0.9",
18-
"@jupyter-widgets/controls": "^5.0.9",
16+
"@jupyter-widgets/base": "^6.0.10",
17+
"@jupyter-widgets/base-manager": "^1.0.11",
18+
"@jupyter-widgets/controls": "^5.0.11",
1919
"codemirror": "^5.48.0",
2020
"font-awesome": "^4.7.0"
2121
},

examples/web3/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jupyter-widgets/example-web3",
3-
"version": "8.0.11",
3+
"version": "8.0.13",
44
"private": true,
55
"description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.",
66
"license": "BSD-3-Clause",
@@ -14,9 +14,9 @@
1414
"test:default": "echo \"No test specified\""
1515
},
1616
"dependencies": {
17-
"@jupyter-widgets/base": "^6.0.8",
18-
"@jupyter-widgets/controls": "^5.0.9",
19-
"@jupyter-widgets/html-manager": "^1.0.11",
17+
"@jupyter-widgets/base": "^6.0.10",
18+
"@jupyter-widgets/controls": "^5.0.11",
19+
"@jupyter-widgets/html-manager": "^1.0.13",
2020
"@jupyterlab/services": "^6.0.0 || ^7.0.0",
2121
"codemirror": "^5.48.0",
2222
"font-awesome": "^4.7.0",

examples/web4/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jupyter-widgets/example-web4",
3-
"version": "8.0.11",
3+
"version": "8.0.13",
44
"private": true,
55
"description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.",
66
"license": "BSD-3-Clause",
@@ -13,7 +13,7 @@
1313
"test:default": "echo \"No test specified\""
1414
},
1515
"dependencies": {
16-
"@jupyter-widgets/html-manager": "^1.0.11",
16+
"@jupyter-widgets/html-manager": "^1.0.13",
1717
"font-awesome": "^4.7.0"
1818
},
1919
"devDependencies": {

0 commit comments

Comments
 (0)