Skip to Content
Jupyter Cookbook
book

Jupyter Cookbook

by Toomey, Nikhil Borkar, Nikhil Akki, Juan Tomás Oliva Ramos
April 2018
Beginner content levelBeginner
238 pages
7h 13m
English
Packt Publishing
Content preview from Jupyter Cookbook

How to do it...

In this example, we put a button control on our Notebook:

  1. First, we reference the widgets library and the library to display the button:
import ipywidgets as widgetsfrom IPython.display import display
  1. We create a button. This is like calling a library function, except that the function returns a widget object:
 my_button = widgets.Button(description='Click My Button')
  1. We need to display the button:
display(my_button)
  1. When the user clicks, we want to print a message in the Notebook. We create the handler for the button clicks (we could've done any number of things, but in this example, we are just adding an output message):
def my_button_clicked(b):    print("You clicked on My Button")
  1. We have to tell the button where ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Cookbook, 3rd Edition

Python Cookbook, 3rd Edition

David Beazley, Brian K. Jones
Pandas 1.x Cookbook - Second Edition

Pandas 1.x Cookbook - Second Edition

Matthew Harrison, Theodore Petrou
bash Cookbook, 2nd Edition

bash Cookbook, 2nd Edition

Carl Albing, JP Vossen

Publisher Resources

ISBN: 9781788839440Supplemental Content