Installing widgets

  • The widgets package is an upgrade to the standard Jupyter installation. You can update the widgets package using this command:
pip install ipywidgets
  • Once complete, you must then upgrade your Jupyter installation using this command:
jupyter nbextension enable --py widgetsnbextension
  • And then you must use this command:
conda update jupyter_core jupyter_client
  • We put together a basic example widget Notebook to make sure everything is working:
 #import our libraries 
from ipywidgets import * 
from IPython.display import display 
 
#create a slider and message box 
slider = widgets.FloatSlider() 
message = widgets.Text(value = 'Hello World') 
 
#add them to the container 
container = widgets.Box(children = (slider, message)) 
container.layout.border = '1px black solid' 
 
display(container) 
  • We end up with the following screenshot, where the container widget is displayed enclosing the slider and the message box:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.161.222