Mastering widgets in the Jupyter Notebook
The ipywidgets package provides many common user interface controls for exploring code and data interactively. These controls can be assembled and customized to create complex graphical user interfaces. In this recipe, we introduce the various ways we can create user interfaces with ipywidgets.
Getting ready
The ipywidgets package should be installed by default in Anaconda, but you can also install it manually with conda install ipywidgets
.
Alternatively, you can install ipywidgets with pip install ipywidgets
, but then you also need to type the following command in order to enable the extension in the Jupyter Notebook:
jupyter nbextension enable --py --sys-prefix widgetsnbextension
How to do it...
- Let's import the packages:
>>> import ipywidgets as widgets from ipywidgets import HBox, VBox import numpy as np import matplotlib.pyplot as plt from IPython.display import display %matplotlib inline
- The
@interact
decorator shows...