August 2018
Beginner
282 pages
5h 51m
English
All of the controls work by reacting to user actions, either with a mouse or keyboard. The default actions for controls are built into the software, but you can add your own handling of events (user actions).
We have seen this kind of event handling previously (for example, in the section on the slidebar, a function is called whenever the slider value is changed by the user). But, let's explore it in a little more depth.
We could have the following script:
from ipywidgets import widgetsfrom IPython.display import displaybutton = widgets.Button(description="Click Me!")display(button)def on_button_clicked(b): print("Button clicked.")button.on_click(on_button_clicked)
This script does the following:
Read now
Unlock full access