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.