Button disappearing on click

I have a button, that after I submit a form, displays. When I click on that button, I want to show some text. However, every time I click that button, it disappears.

def accept():
    st.session_state['button_clicked']['acceptance'] = True

def deny():
    st.session_state['button_clicked']['acceptance'] = False

if 'button_clicked' not in st.session_state:
    st.session_state['button_clicked'] = {'acceptance': False}

col1, col2= st.columns(2)
with col1:
    with st.form("emergency"):
        st.write("Enter emergency: ")
        dr_input = st.text_input('Your query')
        submitted = st.form_submit_button("Submit")

    if submitted:
        full_response = ""
        rag_data = rag(dr_input)
        
        if rag_data[0] == "1":
            st.markdown("Agree below")
            if st.button('Yes', on_click=accept()):
                  st.write("Yay")

How can I prevent it from disappearing?

1 Like