If I understood you correctly, you would like to get the selected date as output, but instead your app returns to the initial state, right ?
This is because of Streamlit’s behaviour of running the app linearly from the very top. Hence, it gets stuck at st.button syntax, and you see no output. A quick workaround, (not ideal) using st.checkbox option. So instead of
Use, check_state = st.checkbox("Start")
One of other possibilities, is to use st.session_state and storing the button’s state.
Thank you for getting back,
Indeed, I tried to implement the st.session_state method, even though I encountered a related problem.
Here is the modified code:
import streamlit as st
st.session_state.button_sent = None
dates = ['2021-01-01',
btn= st.checkbox ('Start')
placeholder_bar = st.empty()
if btn or st.session_state.button_sent:
st.session_state.button_sent = True
output = st.multiselect('Test', options = dates)
the print after the select works well, but the problem is that whenever I select now the options from the select box the whole page refreshed and the first couple of lines (before the select box) re run.
Sure, here I put simple examples with progress bar (0, 30, 50) but in my case the code prior to multiselect button takes more time and I find it weird to re run it on every multiselect selections.