I'm building a small streamlit app which should show various topics' results through pages. So, on page 1 we have basketball, on page 2 volleyball, etc. Selectbox (dropdown) should be present on each page, allowing the user to switch countries. Is there a way for when the user selects the country on i.e. basketball page to save/apply/sync selection on volleyball page (when user switch page to have selected country automatically applied)?
I'm not using select box as method between pages, but have main page and modules. Sport pages are in the separate folder pages.
Host_Country = st.selectbox('Select HomeTeamName name:',('France', 'Spain', 'Italy', 'England', 'Belgium', 'Portugal','Sweden'), key='country')
The selectbox has an index parameter to represent the value that will be shown in the box. We can use it to update the box. We will use session state to update the index in all pages. The country value is already tracked by st.session_state.country.
main.py
baskeball.py
pages/baskeball.py
volleyball.py
pages/volleyball.py
Sample
Select spain in basketball.
Go to volleyball page.
The country is the same!