Skip to content

Commit 22262e8

Browse files
authored
Merge pull request #3501 from vidartf/user-migration
User migration docs for 7.x -> 8.0
2 parents 3ec8ed8 + 1557a16 commit 22262e8

File tree

4 files changed

+97
-1
lines changed

4 files changed

+97
-1
lines changed

docs/source/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A summary of changes in ipywidgets. For more detailed information, see the issues and pull requests for the appropriate milestone on [GitHub](https://github.com/jupyter-widgets/ipywidgets).
44

5-
## [8.0](https://github.com/jupyter-widgets/ipywidgets/releases/tag/v8.0) (not released yet)
5+
## [8.0](https://github.com/jupyter-widgets/ipywidgets/releases/tag/v8.0)
66

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.
88
See also the

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ some custom widget packages built on top of the Jupyter Widgets framework.
9595
:maxdepth: 1
9696

9797
changelog.md
98+
user_migration_guides.md
9899
migration_guides.md
99100

100101
.. toctree::

docs/source/migration_guides.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ is released.
2424
We also recommend testing the migration in a completely new notebook, rather
2525
than one that contains widgets that you instantiated with ipywidgets 7.x.
2626

27+
For a summarized list of relevant changes, please consult the "Developers" section of the
28+
[changelog](./changelog).
29+
2730
### Updating setup.py
2831

2932
Start by updating the dependency in your `setup.py` or `setup.cfg` to support 8.x.

docs/source/user_migration_guides.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Migrating user code
2+
===================
3+
4+
These are migration guides aimed specifically at user of ipywidgets.
5+
6+
Migrating from 7.x to 8.0
7+
-------------------------
8+
9+
For more details about the changes done for the 8.0 major version, please consult the
10+
[changelog](./changelog).
11+
12+
### Code
13+
14+
#### FileUpload
15+
16+
The `data` and `metadata` traits have been removed, and the `value` trait revamped to
17+
be a list of dicts containing the file information. The keys of these dicts are:
18+
19+
- `content`: The buffer of file data
20+
- `name`: The name of the file
21+
- `type`: The MIME type of the file content
22+
- `size`: The size of the buffer in bytes
23+
- `last_modified`: A UTC datetime representing the "last modified" value reported for the file
24+
25+
Suggested migration: Rewrite all usage of `FileUpload` to use the new structure.
26+
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.
28+
29+
#### Tooltips
30+
31+
As part of an effort to make it possible to
32+
[set tooltips for all widgets](https://github.com/jupyter-widgets/ipywidgets/pull/2680),
33+
the old `description_tooltip` attribute for certain widgets was removed. Now all widgets
34+
that inherit `DOMWidget` have the attribute `tooltip` instead.
35+
36+
Suggested migration: Search and replace `description_tooltip` to `tooltip`.
37+
TBD: ipywidgets should add a `description_tooltip` keyword argument to `DescriptionWidget`s, with
38+
a deprecation warning.
39+
40+
#### Selection Widgets
41+
42+
These widgets include: `ToggleButtons`, `Dropdown`, `RadioButtons`, `Select`, `SelectMultiple` `Selection`, `SelectionSlider`, and `SelectionRangeSlider`.
43+
44+
For these, it is no longer possible to use `dict`s or other mapping types as values for the
45+
`options` trait. Using mapping types in this way has been deprecated since version 7.4, and
46+
will now raise a `TypeError`.
47+
48+
Suggested migration: Clean up the `options` use. The following snippet can be used to convert
49+
a `dict` to the new format: `w.options = tuple((str(k), v) for k, v in your_dict.items())`.
50+
51+
#### Description Sanitization
52+
53+
The value of the `description` field of any widget that inherits `DescriptionWidget`
54+
(most widgets in ipywidgets) will now have its value sanitized for certain HTML content
55+
on the client side. If you are relying on HTML in this value, you might need to explicitly
56+
set the `description_allow_html` trait to `True`, depending on what kind of tags/attributes
57+
are used.
58+
59+
Suggested migration: Only set `description_allow_html` if you are in full control of the
60+
value that is set.
61+
62+
#### Layout.border
63+
64+
While this change is strictly speaking backwards compatible, a word of caution is useful to
65+
those that want to use the new functionality:
66+
67+
Four attributes have been added: `border_left`, `border_right`, `border_top` and `border_bottom`.
68+
These can be used to set the corresponding CSS border strings individually. Setting the
69+
`border` property overrides all of those four attributes to the new value of `border`. If
70+
the individual values are set to different values, *the `border` property will return `None`
71+
when you read its value*.
72+
73+
#### Layout.overflow_x / overflow_y
74+
75+
The previously deprecated traits `overflow_x` and `overflow_y`
76+
[have been removed](https://github.com/jupyter-widgets/ipywidgets/pull/2688). Please
77+
use the `overflow` trait instead.
78+
79+
### Deployments
80+
81+
#### Embedded CDN
82+
83+
Please note that the default CDN of ipywidgets have changed from unpkg to jsDelivr. If
84+
you rely on the CDN being unpkg, this can be overridden by specifying the data
85+
attribute `data-jupyter-widgets-cdn` on the HTML manager script tag. See
86+
[embedding](./embedding) for details.
87+
88+
#### widgetsnbextension
89+
90+
The `widgetsnbextension` package is no longer a dependency of `ipywidgets`. Consequently,
91+
neither is the `notebook` package. If you need to keep `notebook` and widget support for it
92+
you will need to ensure they are explicitly stated in any environment bootstrapping.

0 commit comments

Comments
 (0)