103 Add input widgets
Instructions
Add to app.py to recreate this app.
- Don’t forget to load the submodules you will need.
- Arrange for the second widget to store the value
"prod_score"
when Product Score is selected, and the value"training_score"
when Training Score is selected.
#| standalone: true
#| components: [viewer]
#| layout: horizontal
#| viewerHeight: 800
from shiny.express import ui
accounts=[
"Berge & Berge",
"Fritsch & Fritsch",
"Hintz & Hintz",
"Mosciski and Sons",
"Wolff Ltd",
]
ui.input_select(
id="account",
label="Account",
choices=accounts
)
ui.input_radio_buttons(
"variable",
"Select a variable to plot",
choices={
"prod_score": "Product Score",
"training_score": "Training Score"
}
)
#| standalone: true
#| components: [editor, viewer]
#| layout: horizontal
#| viewerHeight: 800
accounts=[
"Berge & Berge",
"Fritsch & Fritsch",
"Hintz & Hintz",
"Mosciski and Sons",
"Wolff Ltd",
]
#| standalone: true
#| components: [editor, viewer]
#| layout: horizontal
#| viewerHeight: 800
from shiny.express import ui
accounts=[
"Berge & Berge",
"Fritsch & Fritsch",
"Hintz & Hintz",
"Mosciski and Sons",
"Wolff Ltd",
]
ui.input_select(
id="account",
label="Account",
choices=accounts
)
ui.input_radio_buttons(
"variable",
"Select a variable to plot",
choices={
"prod_score": "Product Score",
"training_score": "Training Score"
}
)
The source code for this exercise is at https://github.com/posit-conf-2024/intro-to-shiny-for-python/tree/main/docs/exercises/103-inputs.