Download button data parameter issues

Hi,

Im trying to make a generate report button. Using st.download_button, I want so that on click I can run some expensive code that then generates a pdf file to download. As of now this “expensive pdf generation code” to produce data to download has to be done decoupled from the button.

Having it decoupled, it runs everytime the app is changed in terms of interaction (caching does not solve the issue) making user experience really slow.

Is there a way to make the data param wait? Or be able to pass a function that it will only run on click.

1 Like