The button inside a button seems to reset the whole app.Why?

Hey @Anotar, i was checking your issue and this seems to be related to this topic Preserving state across sidebar pages, in which the solution was to use SessionState, so you could do something like this:

import streamlit as st
import SessionState


def main():
    st.subheader("new")

    session_state = SessionState.get(name="", button_sent=False)

    session_state.name = st.text_input("Enter your name")
    button_sent = st.button("Send")

    if button_sent:
        session_state.button_sent = True

    if session_state.button_sent:
        st.write(session_state.name)

        session_state.bye = st.checkbox("bye")
        session_state.welcome = st.checkbox("welcome")

        if session_state.bye:
            st.write("I see")
        if session_state.welcome:
            st.write("you see")


main()

Please let me know if this helps you

3 Likes