Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13981

Streamlit multiple nested buttons, not working

$
0
0

I am trying to implement streamlit UI and two mutually exclusive operation button. each operation has nested streamlit buttons. The buttons behavior should be like if i click on one button, than another should be reset, also if i repeat clicking button, operations and nested buttons of that particular button should be visible and working for that perticular button only.I tried multiple approaches. i solved nested button problem using st.session state. but when i select second button after clicking on first button, content from first button is still there, which i dont expect . vice versa.please help me to solve this

sideb=st.sidebarbutton1 = sideb.button('Single')if st.session_state.get('button') != True:    st.session_state['button'] = button1 # Saved the stateif st.session_state['button'] == True:    st.write("button1 is True")    option=st.selectbox('Select App?',            ('A', 'B', 'C'),index=0)    st.write('You selected:', option)    option=option.lower()''''SOME CHATTING APP WITHOUT ANY BUTTON '''button2 = sideb.button('Multiple Queries')if st.session_state.get('button2') != True:    st.session_state['button2'] = button2 # Saved the stateif st.session_state['button2'] == True:    uploaded_file = st.file_uploader("Choose a file with app_name and list_of questions.", type=['xlsx'], accept_multiple_files=False)    st.write("button2 is True")    if uploaded_file is not None:        stqdm.pandas()        df=pd.read_excel(uploaded_file)    if st.button('Generate'):        st.write("Do your logic here")        with st.spinner('Wait for it...'):            df['Answers']=df.progress_apply(qs, axis=1)            AgGrid(df)        st.success('Done!')        csv = convert_df(df)        download2 = st.download_button(            label="Download Answers",            data=csv,            file_name='Answers.csv',            key='download-csv'        )

Viewing all articles
Browse latest Browse all 13981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>