I have a simple code where, I click on process button which generates two button and on clicking any two download button the button and page data should stay as it is.
However when I use any download button, the generated buttons go away.
I want to generate the button and keep all the stuff no matter how many times we click it, tried using sessions, please look:
import streamlit as st
def main():
st.write("Initial code")
if "process_btn" not in st.session_state:
st.session_state.process_btn = False
if st.button("Process") or st.session_state.process_btn:
st.session_state.process_btn = True
file1 = open('sample1.xlsx', "rb")
file2 = open('sample2.xlsx', "rb")
if "load_excel" not in st.session_state:
st.session_state.load_excel = st.download_button(label='📥 Download sample1', data = file1, file_name= 'sample1.xlsx')
st.write("first")
if "load_json" not in st.session_state:
st.session_state.load_json = st.download_button(label='📥 Download sample2', data = file2, file_name= 'sample2.xlsx')
st.write("second")
if st.session_state.load_excel:
# st.session_state.load_excel = True
st.write("third")
if st.session_state.load_json:
st.write("fourth")
# st.session_state.load_json = True
if __name__ == '__main__':
main()
This is main page.
but after clicking any download button its like this:
it should have stayed as homepage .
any help on this!!