Hello everyone,
I’m blocking on something with Streamlit.
I have a multiselect then 2 radios, the 2 radios are kinda connected between them
Without using form, streamling is running everytime I’m changing the radio or if I am doing something in the multiselect.
So I tried to use a form for all of these, but when I’m changing my radio, nothing is happening, it’s stucked
My actual code:
import streamlit as st
options_players = st.multiselect(
'Compare players (max 7)',
df_pos.player_slug.unique(), max_selections=7)
col1, col2, col3 = st.columns(3)
option = st.radio('Select :',
['Season',
'Year',
'Lasts'],
horizontal=True)
if option == "Season":
option_calendar = st.radio('Select :',
['2022-2023',
'2021-2022',
'2020-2021'],
horizontal=True)
if option == "Year":
option_calendar = st.radio('Select :',
['2023',
'2022',
'2021'],
horizontal=True)
option_lasts = False
if option == "Lasts":
option_calendar = False
option_lasts = st.radio('Select :',
['L40',
'L15',
'L5'],
horizontal=True)
search_button = st.button('Search')
The form I tried :
import streamlit as st
form = st.form("my_form")
options_players = form.multiselect(
'Compare players (max 7)',
df_pos.player_slug.unique(), max_selections=7)
col1, col2, col3 = form.columns(3)
option = form.radio('Select :',
['Season',
'Year',
'Lasts'],
horizontal=True)
if option == "Season":
option_calendar = form.radio('Select :',
['2022-2023',
'2021-2022',
'2020-2021'],
horizontal=True)
if option == "Year":
option_calendar = form.radio('Select :',
['2023',
'2022',
'2021'],
horizontal=True)
option_lasts = False
if option == "Lasts":
option_calendar = False
option_lasts = form.radio('Select :',
['L40',
'L15',
'L5'],
horizontal=True)
search_button = form.form_submit_button("Search")
What would be the best way to do that (if it’s possible) ?
Thanks for your help.