The listbox widget

We could also use the listbox widget, called a Dropdown, as in the following script:

import ipywidgets as widgets 
from IPython.display import display 
w = widgets.Dropdown( 
    options={'Pen': 7732, 'Pencil': 102, 'Pad': 33331}, 
    description='Item:', 
) 
display(w) 
w.value 

This script will display a listbox to the user with the values Pen, Pencil, and Pad. When the user selects one of the values, the associated value is returned in the w variable, which we display as in the following screenshot:

Therefore, we see the inventory value associated with Pen.

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

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