Interactive Widgets for the Jupyter Notebook
See the 8.0.0 changelog for a more comprehensive summary of changes. To see the full list of pull requests and issues, see the 8.0 milestone on GitHub, or the full list of changes since 7.x.
Here are some highlights of user-visible changes in ipywidgets 8.0.
In addition to the existing DatePicker widget, we now have new DatetimePicker and TimePicker widgets. (#2715)
from ipywidgets import VBox, TimePicker, DatetimePicker
VBox([
TimePicker(description='Time'),
DatetimePicker(description='Date/Time')
])
The new TagsInput widget provides an easy way to collect and manage tags in a widget. You can drag and drop tags to reorder them, limit them to a set of allowed values, or even prevent making duplicate tags. (#2591, #3272)
from ipywidgets import TagsInput
TagsInput(
value=['pizza', 'fries'],
allowed_tags=['pizza', 'fries', 'tomatoes', 'steak'],
allow_duplicates=False
)
Similarly, the new ColorsInput widget provides a way to select colors as tags
from ipywidgets import ColorsInput
ColorsInput(
value=['red', '#2f6d30'],
# allowed_tags=['red', 'blue', 'green'],
# allow_duplicates=False
)
The new Stack container widget shows only the selected child widget, while other child widgets remain hidden. This can be useful if you want to have a area that displays different widgets depending on some other interaction.
from ipywidgets import Stack, Button, IntSlider, Dropdown, VBox, link
s = Stack([Button(description='Click here'), IntSlider()], selected_index=0)
d = Dropdown(options=['button', 'slider'])
link((dropdown, 'index'), (stacked, 'selected_index'))
VBox([d, s])
The file upload widget has been overhauled to handle multiple files in a more useful format:
.value
attribute is now a list of dictionaries, rather than a dictionary mapping the uploaded name to the content..content
key, e.g., uploader.value[0].content
..data
attribute has been removed..metadata
attribute has been removed.See the user migration guide for details on how to migrate your code.
Many style and layout options have been added to core widgets:
from ipywidgets import Button
Button(description="Click me", tooltip='An action')
border_top
, border_right
, border_bottom
, border_left
attributes (#2757, #3269)
from ipywidgets import Button
Button(description="Click me", layout={'border_bottom': '3px solid blue'})
description_allow_html
attribute (HTML content is still sanitized for security). (#2785)
from ipywidgets import Text
Text(description="<b>Name</b>", description_allow_html=True)
handle_color
style attribute (#3142)The Accordion, Tab, and Stack widgets now have a .titles
attribute that you can use to get and set titles from the constructor or as an attribute. (#2746, #3296, #3477)
from ipywidgets import Tab, IntSlider, Text
Tab([IntSlider(), Text()], titles=('Slider', 'Text'))
The slider implementation in the core widgets now uses nouislider. This enables us to fix long-standing bugs and introduce new features, like dragging the range in a RangeSlider. (#2712, #630, #3216, #2834)
By default, ipywidgets 8 enables a collaboration mode, where widget updates from one frontend are reflected back to other frontends, enabling a consistent state between multiple users and fixing synchronization between the kernel and frontend. You may want to disable these update echo messages if they are using too much bandwidth or causing slower interactivity. To disable echo update messages across ipywidgets, set the environment variable JUPYTER_WIDGETS_ECHO
to 0
. For widget authors, to opt a specific attribute of custom widget out of echo updates (for example, if the attribute contains a lot of data that does not need to be synchronized), tag the attribute with echo_update=False
metadata (we do this in core for the FileUpload widget's data
attribute). (#3195, #3343, #3394, #3407)
We have made it easier to load widgets from content delivery networks.
data-jupyter-widgets-cdn-only
attribute to load modules only from CDN (#2792, #2786)Here is a short list of some of the other changes in ipywidgets 8.0.
on_displayed
Python callback mechanism (#2021)To see an overview of the changes to the core widget model specification, see #3455.
Widget.widgets
and Widget.widget_types
are now private variables (#3122, #3173)_repr_mimebundle_
and require ipython 6.1 or later. (#2021, #1811)set_state
+ fix selection widgets flakiness (#3271)handle_kernel
alias (#2694)register
decorator (#2695)display_model
and display_view
(#2752, #2751)jupyter-widgets
from jp-outputarea-output
node (#2500)pWidget
to luminoWidget
and deprecate pWidget
(#3118, #3141, #3358,)layout
, style
, and shown
events (#3300)jupyter.widget.control
comm channel (#3313)process.cwd
polyfill (#3315)widget
and introduce a similar jupyter-widget
CSS class (#3146).get_model()
method always return a Promise, which is rejected if the requested model is not registered. To test if a model is registered, use the new .has_model()
method (#3389)Full Changelog: https://github.com/jupyter-widgets/ipywidgets/compare/7.x...8.0.0
To see the full list of pull requests, see the 7.7.1 milestone on GitHub.
Highlights include:
To see the full list of pull requests and issues, see the 7.7 milestone on GitHub.
Highlights include:
has_model
method for synchronously checking if a widget model is registered. #3377
JUPYTER_WIDGETS_ECHO
to 1. To opt a specific attribute out of echo updates, tag the attribute with echo_update=False
metadata (we do this in core for the FileUpload widget's data
attribute). #3400, #3394
A minor release in 7.6.x series.
From changelog.md:
To see the full list of pull requests and issues, see the 7.6.0 milestone on GitHub.
The main change in this release is that installing ipywidgets
7.6.0 will now automatically enable ipywidgets support in JupyterLab 3.0—a user has no extra JupyterLab installation step and no rebuild of JupyterLab, nor do they need Node.js installed. Simply install the python ipywidgets package with pip (pip install ipywidgets==7.6.0
) or conda/mamba (conda install -c conda-forge ipywidgets=7.6.0
) and ipywidgets will automatically work in classic Jupyter Notebook and in JupyterLab 3.0.
This is accomplished with the new python package jupyterlab_widgets
version 1.0, on which ipywidgets
7.6.0 now depends (similar to how ipywidgets
already depends on the widgetsnbextension
package to configure ipywidgets for the classic Jupyter Notebook). The jupyterlab_widgets
Python package is a JupyterLab 3.0 prebuilt extension, meaning that it can be installed into JupyterLab 3.0 without rebuilding JupyterLab and without needing Node.js installed.
Custom widget maintainers will need to make two changes to update for JupyterLab 3:
Update the @jupyter-widgets/base
dependency version to include ^4
to work in JupyterLab 3.0. For example, if you had a dependency on @jupyter-widgets/base
version ^2 || ^3
, update to ^2 || ^3 || ^4
for your widget to work in classic Jupyter Notebook, JupyterLab 1, JupyterLab 2, and JupyterLab 3. See #2472 for background.
In the package.json
, add the following sharedPackages
configuration inside the jupyterlab
key. See the JupyterLab extension documentation for more information.
"jupyterlab": {
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
"singleton": true
}
}
}
Separate from these two steps to update for JupyterLab 3, we also recommend that you make your widget's JupyterLab extension a prebuilt extension for JupyterLab 3.0. Users will be able to install your JupyterLab 3.0 prebuilt extension without rebuilding JupyterLab or needing Node.js. See the JupyterLab 3 extension developer documentation or the new widget extension cookiecutter for more details.
See http://blog.jupyter.org/2017/03/01/ipywidgets-6-release/ for the release announcement.