-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Problem
The Streamlit app reloads entirely when clicking on a st.download_button. In my case, I think it should not: download buttons are different from buttons and should not trigger a reload of the app. They should only trigger a download.
I perfectly understand that a click on a button does reload the app (to recompute) but downloads don't change the view, downloads don't trigger computations etc.
I also know about the cache, but it is not always a proper solution: what about apps with a st.forms? The user should not have to click on yet another button to generate the same view that has not changed one bit. The same goes if several files can be downloaded: it can be very cumbersome to do such a simple task.
Solution
Several options:
- Stop reloading the app for a
st.download_button - Add a parameter to trigger (or not) a reload of the page when clicking on a
st.download_button.
Additional context
See this discourse: https://discuss.streamlit.io/t/stop-page-from-reloading-after-using-downloader/18744
And this code to reproduce the problem exposed above:
import streamlit as st
def long_computation():
import time
time.sleep(10)
st.header("TEST DOWNLOAD BUTTON")
with st.spinner("Running a long computation.."):
long_computation()
st.download_button("Download", "a")Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the π (thumbs up emoji) reaction in response to the initial post.