Skip to content

Commit b95b6f9

Browse files
authored
Merge pull request #3539 from jasongrout/migrating
Update docs
2 parents c7eac80 + 2e107f2 commit b95b6f9

File tree

7 files changed

+67
-41
lines changed

7 files changed

+67
-41
lines changed

docs/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ To build the ipywidgets documentation:
55
1. Install the development version of ipywidgets with the `dev-install.sh` script in the repo root directory.
66
2. Install the Python packages for building documentation with either mamba or conda:
77
```sh
8-
conda update --file docs/environment.yml
8+
conda env update --file docs/environment.yml
99
```
1010

1111
or with `pip`:

docs/source/changelog.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This is a summary of changes in ipywidgets releases. For more detailed informati
77
To see the full list of pull requests and issues, see the [8.0 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/30?closed=1) on GitHub, or the
88
[full list of changes since 7.x](https://github.com/jupyter-widgets/ipywidgets/compare/7.x...master).
99

10+
See the [user migration guide](./user_migration_guides.md) for suggestions about migrating your code that uses ipywidgets to 8.0.
11+
12+
If you author a custom widget, please see the [migration guide](./migration_guides.md) for suggestions about migrating your widget to support ipywidgets 8.
13+
1014
### Users
1115

1216
Here are some highlights of user-visible changes in ipywidgets 8.0.
@@ -63,13 +67,17 @@ VBox([d, s])
6367

6468
The file upload widget has been overhauled to handle multiple files in a more useful format:
6569

66-
- The `.value` attribute is now a list of dictionaries, rather than a dictionary mapping the uploaded name to the content. To retrieve the original form, use `{f["name"]: f.content.tobytes() for f in uploader.value}`.
70+
- The `.value` attribute is now a list of dictionaries, rather than a dictionary mapping the uploaded name to the content.
6771
- The contents of each uploaded file is a [memory view](https://docs.python.org/3/library/stdtypes.html#memory-views) in the `.content` key, e.g., `uploader.value[0].content`.
68-
- The `.data` attribute has been removed. To retrieve it, use `[f.content.tobytes() for f in uploader.value]`.
69-
- The `.metadata` attribute has been removed. To retrieve it, use `[{k: v for k, v in f.items() if k != "content"} for f in w.value]`.
72+
- The `.data` attribute has been removed.
73+
- The `.metadata` attribute has been removed.
74+
75+
See the [user migration guide](./user_migration_guides.md#FileUpload) for details on how to migrate your code.
7076

7177
([#2767](https://github.com/jupyter-widgets/ipywidgets/pull/2767), [#2724](https://github.com/jupyter-widgets/ipywidgets/pull/2724), [#2666](https://github.com/jupyter-widgets/ipywidgets/pull/2666), [#2480](https://github.com/jupyter-widgets/ipywidgets/issues/2480))
7278

79+
80+
7381
#### More styling options
7482

7583
Many style and layout options have been added to core widgets:
@@ -117,7 +125,7 @@ We have made it easier to load widgets from content delivery networks.
117125

118126
- The default CDN is changed from unpkg to jsDelivr ([#3121](https://github.com/jupyter-widgets/ipywidgets/pull/3121), [#1627](https://github.com/jupyter-widgets/ipywidgets/issues/1627))
119127
- You can use the `data-jupyter-widgets-cdn-only` attribute to load modules only from CDN ([#2792](https://github.com/jupyter-widgets/ipywidgets/pull/2792), [#2786](https://github.com/jupyter-widgets/ipywidgets/issues/2786))
120-
- We have updated the webpack public path settings so the HTMLManager and the Jupyter Notebook extensions pull assets from wherever they are loaded, rather than only from CDN. [#3464](https://github.com/jupyter-widgets/ipywidgets/pull/3464), [#3508](https://github.com/jupyter-widgets/ipywidgets/pull/3508)
128+
- We have updated the webpack public path settings so the HTMLManager and the Jupyter Notebook extensions pull assets from wherever they are loaded, rather than only from CDN. If you author a custom widget, we highly encourage you to apply similar changes to your widget by adapting the changes at https://github.com/jupyter-widgets/widget-cookiecutter/pull/103/files. [#3464](https://github.com/jupyter-widgets/ipywidgets/pull/3464), [#3508](https://github.com/jupyter-widgets/ipywidgets/pull/3508)
121129

122130

123131
#### Other changes

docs/source/examples/Layout Templates.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"source": [
77
"# Using Layout Templates\n",
88
"\n",
9-
"As we showed in [Layout and Styling of Jupyter widgets](Widget%20Styling.ipynb) multiple widgets can be arranged together using the flexible [GridBox](Widget%20Styling.ipynb#The-Grid-Layout) specification. However, use of the specification involves some understanding of CSS properties and may impose sharp learning curve. Here, we will describe layout templates built on top of `GridBox` that simplify creation of common widget layouts."
9+
"As we showed in [Layout of Jupyter widgets](Widget%20Layout.ipynb), multiple widgets can be arranged together using the flexible [GridBox](Widget%20Styling.ipynb#The-Grid-Layout) specification. However, use of the specification involves some understanding of CSS properties and may impose sharp learning curve. Here, we will describe layout templates built on top of `GridBox` that simplify creation of common widget layouts."
1010
]
1111
},
1212
{

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ some custom widget packages built on top of the Jupyter Widgets framework.
100100
examples/Widget List.ipynb
101101
examples/Output Widget.ipynb
102102
examples/Widget Events.ipynb
103-
examples/Widget Layout.ipynb
104103
examples/Widget Styling.ipynb
104+
examples/Widget Layout.ipynb
105105
examples/Layout Templates.ipynb
106-
examples/Widget Custom.ipynb
107106
examples/Using Interact.ipynb
107+
examples/Widget Custom.ipynb
108108
examples/Widget Low Level.ipynb
109109
examples/Widget Asynchronous.ipynb
110110
embedding.md

docs/source/migration_guides.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ than one that contains widgets that you instantiated with ipywidgets 7.x.
2727
For a summarized list of relevant changes, please consult the "Developers" section of the
2828
[changelog](./changelog).
2929

30+
You may consider updating your widget by generating a new widget from the cookiecutter at https://github.com/jupyter-widgets/widget-cookiecutter and adapting the changes to your widget. The widget cookiecutter has been updated to use best practices in Python packaging and Jupyter Widget infrastructure.
31+
3032
### Updating setup.py
3133

3234
Start by updating the dependency in your `setup.py` or `setup.cfg` to support 8.x.
@@ -68,6 +70,10 @@ The ``ManagerBase`` class has been split into an interface type `IWidgetManager`
6870
+ "@jupyter-widgets/base-manager": "^1",
6971
```
7072

73+
### Updating the AMD module logic
74+
75+
We highly encourage you to update your widget's logic around generating AMD modules for the CDN with changes similar to those at https://github.com/jupyter-widgets/widget-cookiecutter/pull/103/files. These changes allow your AMD module to be hosted anywhere, rather than hardcoding the `unpkg.com` CDN, and they remove the differences between the AMD module generated for the notebook extension and the AMD module generated for the CDN.
76+
7177
### Updating the client-side code
7278

7379
#### Phosphor -> Lumino

docs/source/user_install.md

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Users can install the current version of **ipywidgets** with
55
[pip](https://pip.pypa.io/en/stable/) or
66
[conda](https://conda.readthedocs.io/en/latest/).
77

8-
In most cases, installing the Python `ipywidgets` package will also automatically configure classic Jupyter Notebook and JupyterLab 3.0 to display ipywidgets. With pip, do:
8+
In most cases, installing the Python `ipywidgets` package will also automatically configure classic Jupyter Notebook and JupyterLab 3.x to display ipywidgets. With pip, do:
99

1010
``` bash
1111
pip install ipywidgets
@@ -17,61 +17,52 @@ or with conda, do:
1717
conda install -c conda-forge ipywidgets
1818
```
1919

20-
Installing in classic Jupyter Notebook
21-
--------------------------------------
22-
23-
Most of the time, installing `ipywidgets` automatically configures Jupyter Notebook to use widgets. The `ipywidgets` package does this by depending on the `widgetsnbextension` package, which configures the classic Jupyter Notebook to display and use widgets. If you have an old version of Jupyter Notebook installed, you may need to manually enable the ipywidgets notebook extension with:
24-
25-
```bash
26-
jupyter nbextension enable --py widgetsnbextension
27-
```
28-
29-
When using [virtualenv](https://virtualenv.pypa.io/en/stable/) and working in
30-
an activated virtual environment, the ``--sys-prefix`` option may be required
31-
to enable the extension and keep the environment isolated (i.e.
32-
``jupyter nbextension enable --py widgetsnbextension --sys-prefix``).
20+
Installing in JupyterLab 3.x
21+
----------------------------
3322

23+
Most of the time, installing `ipywidgets` automatically configures JupyterLab 3.x to use widgets. The `ipywidgets` package does this by depending on the `jupyterlab_widgets` package, which configures JupyterLab 3 to display and use widgets.
3424

35-
If your Jupyter Notebook and the IPython kernel are installed in different
25+
If JupyterLab and the IPython kernel are installed in different
3626
environments (for example, separate environments are providing different
3727
Python kernels), then the installation requires two steps:
3828

39-
1. Install the `widgetsnbextension` package in the environment
40-
containing the Jupyter Notebook server.
29+
1. Install the `jupyterlab_widgets` package in the environment containing JupyterLab.
4130
2. Install `ipywidgets` in each kernel's environment that will use ipywidgets.
4231

43-
For example, if using conda environments, with Jupyter Notebook installed on the
44-
`base` environment and the kernel installed in an environment called `py36`,
32+
For example, if using conda environments, with JupyterLab installed on the
33+
`base` environment and the kernel installed in an environment called `pyenv`,
4534
the commands are:
4635

4736
```bash
48-
conda install -n base -c conda-forge widgetsnbextension
49-
conda install -n py36 -c conda-forge ipywidgets
37+
conda install -n base -c conda-forge jupyterlab_widgets
38+
conda install -n pyenv -c conda-forge ipywidgets
5039
```
5140

52-
Installing in JupyterLab 3.0
53-
----------------------------
5441

55-
Most of the time, installing `ipywidgets` automatically configures JupyterLab 3.0 to use widgets. The `ipywidgets` package does this by depending on the `jupyterlab_widgets` package, version 1.0, which configures JupyterLab 3 to display and use widgets.
42+
Installing in classic Jupyter Notebook
43+
--------------------------------------
44+
45+
Most of the time, installing `ipywidgets` automatically configures Jupyter Notebook to use widgets. The `ipywidgets` package does this by depending on the `widgetsnbextension` package, which configures the classic Jupyter Notebook to display and use widgets.
5646

57-
If your JupyterLab and the IPython kernel are installed in different
47+
If your Jupyter Notebook and the IPython kernel are installed in different
5848
environments (for example, separate environments are providing different
5949
Python kernels), then the installation requires two steps:
6050

61-
1. Install the `jupyterlab_widgets` package (version 1.0 or later) in the environment
62-
containing JupyterLab.
51+
1. Install the `widgetsnbextension` package in the environment
52+
containing the Jupyter Notebook server.
6353
2. Install `ipywidgets` in each kernel's environment that will use ipywidgets.
6454

65-
For example, if using conda environments, with JupyterLab installed on the
66-
`base` environment and the kernel installed in an environment called `py36`,
55+
For example, if using conda environments, with Jupyter Notebook installed on the
56+
`base` environment and the kernel installed in an environment called `pyenv`,
6757
the commands are:
6858

6959
```bash
70-
conda install -n base -c conda-forge jupyterlab_widgets
71-
conda install -n py36 -c conda-forge ipywidgets
60+
conda install -n base -c conda-forge widgetsnbextension
61+
conda install -n pyenv -c conda-forge ipywidgets
7262
```
7363

7464

65+
7566
Installing into JupyterLab 1 or 2
7667
---------------------------------
7768

@@ -103,6 +94,23 @@ running the `jupyter lab clean` command which will remove the staging and
10394
static directories from the lab directory. The location of the lab directory
10495
can be queried by executing the command `jupyter lab path` in your terminal.
10596

97+
Installing into classic Jupyter Notebook 5.2 or earlier
98+
-------------------------------------------------------
99+
100+
If you have an old version of Jupyter Notebook installed (version 5.2 or
101+
earlier), you may need to manually enable the ipywidgets notebook extension
102+
with:
103+
104+
```bash
105+
jupyter nbextension enable --py widgetsnbextension
106+
```
107+
108+
When using [virtualenv](https://virtualenv.pypa.io/en/stable/) and working in
109+
an activated virtual environment, the ``--sys-prefix`` option may be required
110+
to enable the extension and keep the environment isolated (i.e.
111+
``jupyter nbextension enable --py widgetsnbextension --sys-prefix``).
112+
113+
106114
Frequently Asked Questions
107115
--------------------------
108116

docs/source/user_migration_guides.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ be a list of dicts containing the file information. The keys of these dicts are:
2424

2525
Suggested migration: Rewrite all usage of `FileUpload` to use the new structure.
2626
If you need to support both 7.x and 8.x, you can e.g. write functions `get_file_buffer` and similar
27-
to wrap reads from the widget.
27+
to wrap reads from the widget:
28+
29+
- For the `.value` attribute, to retrieve it in the original form, use `{f["name"]: f.content.tobytes() for f in uploader.value}`.
30+
- For the `.data` attribute, use `[f.content.tobytes() for f in uploader.value]`.
31+
- For the `.metadata` attribute, use `[{k: v for k, v in f.items() if k != "content"} for f in w.value]`.
2832

2933
#### Tooltips
3034

@@ -79,7 +83,7 @@ use the `overflow` trait instead.
7983

8084
#### Embedded CDN
8185

82-
Please note that the default CDN of ipywidgets have changed from unpkg to jsDelivr. If
86+
Please note that the default CDN of ipywidgets has changed from unpkg to jsDelivr. If
8387
you rely on the CDN being unpkg, this can be overridden by specifying the data
8488
attribute `data-jupyter-widgets-cdn` on the HTML manager script tag. See
8589
[embedding](./embedding) for details.

0 commit comments

Comments
 (0)