Mein Code unter Jupyter Notebook:
Code: Alles auswählen
import ipywidgets as widgets
from ipywidgets import Button, Layout# dies braucht für grösse des Feldes
from IPython.display import display
Welche_Kiste =[
"Kiste 1",
"Kiste 2",
"Kiste 3"
]
Text_options = Welche_Kiste
Text_Liste = widgets.Dropdown(description="Kiste", options=Text_options,layout=Layout(width='21%', height='30px'))
display(Text_Liste)
print(f' Die {Text_Liste.value} enthält:')
if Text_Liste.value == "Kiste 1":
inhalt =[
"Apfel",
"Melone",
"Zitrone"
]
elif Text_Liste.value == "Kiste 2":
inhalt =[
"Kartoffel",
"Tomaten",
"Ruebli"
]
elif Text_Liste.value == "Kiste 3":
inhalt = [
"Mehl",
"Zucker",
"Salz"
]
Text_options = inhalt
Text_inhalt = widgets.Dropdown(description="Inhalt", options=Text_options,layout=Layout(width='21%', height='30px'))
display(Text_inhalt)
Gruss
Werner