1-st button delete result of 2-nd button

I have 2 button (for print text).
Click on 1-st button - result (text1)
Click on 2-nd button - result (text2), but text1 is disappeared.
Haw fix it?

If you need changes to accumulate, you’ll need to use session_state. If you have some action or conditional statement that results in some st.write() that won’t accumulate since Streamlit does not act like a console log.

Instead, create an object in session_state into which you can accumulate your changes.

import streamlit as st

# Condition to create an empty list the first time the page loads
if 'log' not in st.session_state:
    st.session_state.log = []

# Some conditional or callback function process will add to the log
st.session_state.log.append('some new thing')

for msg in st.session_state.log:
    st.write(msg)
1 Like

That helped. Thank you :grinning: