I want to give the user an option to download an image via st.download_button, but only render the image in case the button is clicked (expensive render). I was thinking there should be some option so that only clicking the button evaluates what would be downloaded, e.g.
The only workaround I can think off right now is sticking the download-button inside a regular button (obviously super ugly), or a custom download button implementation. Any other ideas?
The download button needs to be passed the data upon rendering the button, so if you want to delay the gathering/compiling of that data then you may be forced into using a custom component or script injection.
Here is a post about scripting a download from just before the download button existed so you can modify it to your needs: