Py.Cafe

maartenbreddels/

solara-conditional-form

Selecting Countries and Continent

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
import solara
import state
        

@solara.component
def Page():
    print("Render", state.form.continent, state.form.country)
    with solara.Card("Where do you live?"):
        # continent cannot be 2 way bound, since setting it can have effects
        solara.Select(label="Continent", value=state.form.continent, values=list(state.continents), on_value=state.form.set_continent)
        # country can be simply 2 way bound
        solara.Select(label="Country", value=state.form.country, values=state.countries[state.form.continent])
state.py
1
Could not load content