'Interact Ipywidget form with a function
I created a form with Ipywidget, but got some problems to "link" the chosen drop-down option with the "naïve" function f1.
import warnings
warnings.filterwarnings('ignore')
from ipywidgets import Layout, Button, Box, FloatText, Textarea, Dropdown, Label, IntSlider, widgets
form_item_layout = Layout(
display='flex',
flex_flow='row',
justify_content='space-between'
)
form_items = [
Box([Label(value='Material 1'),
Dropdown(options=crude.columns)], layout=form_item_layout),
Box([Label(value='Material 2'),
Dropdown(options=refinery['Material'].unique())], layout=form_item_layout)
]
form = Box(form_items, layout=Layout(
display='flex',
flex_flow='column',
border='solid 2px',
align_items='stretch',
width='30%'
))
def f1(material):
print(material)
w = interact(f1, material=form._trait_values['children'][1])
display(w)
I've been trying to open the methods and attributes, but got no success for while...
How can I put the selected box' item into the function?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
