Summary
When I want to use st.button and st.file_uploader, I found the click the button will make the file_uploader exec twice. Is this by designed? if so, how I can avoid it exec twice.
Steps to reproduce
uploaded_file = st.file_uploader(“Choose a file”)
if uploaded_file is not None:
time.sleep(5)
print(“test”)
if st.button(“test”):
st.info(“test”)
Code snippet:
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
time.sleep(5)
print("test")
if st.button("test"):
st.info("test")
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
the print(test) will not exec two times.
Actual behavior:
Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.
Debug info
- Streamlit version: Streamlit, version 1.19.0
- Python version: 3.8.9