Hey!! I did it using empty() & session run id. Thanks!! But how can I do a reset of all components means the app on each run. Do, I need to change the session key for all components?
import streamlit as st
import st_state_patch
import SessionState
def main():
st.title("Data Categorization")
session = SessionState.get(txt = '',run_id=0)
controler = st.empty()
session.txt = controler.text_area("Paste your data here..")
print(controler)
print(session.txt)
s = st.State()
if not s:
s.pressed_first_button = False
if st.button("Find Category") or s.pressed_first_button:
session.run_id += 1
s.pressed_first_button = True # preserve the info that you hit a button between runs
try:
if session.txt != '':
value = st.selectbox("Agree with result", ["Yes, I agree..", "Nah!! I don't"])
if st.button("Submit report"):
if value == "Yes, I agree..":
st.write('Do this ...')
elif value != "Nah!! I don't agree":
st.write('Do that ...')
controler.text_area("Paste your data here..", key=session.run_id)
else:
st.write('No content found')
except Exception as ex:
st.write('Looks like I am having problem connecting my backend')
print(ex)
if __name__ == '__main__':
main()