Hi all,
I need to ensure that, when I click on the “Reports” or “Analysis” button, the information previously selected in the “document_options” variable no longer appears on the screen. I have already tried using “del session_state” when clicking on one of the buttons, but it doesn’t work. anyone here to help me?
import streamlit as st
def list_docs():
st.title("Test")
st.write("")
if "selected_option_case" not in st.session_state:
st.session_state.selected_option_case = None
if "selected_document_prev" not in st.session_state:
st.session_state.selected_document_prev = None
case_options = ["0001", "0002", "0003", "0004"]
selected_case = st.selectbox("**Select a case**", case_options, key="selected_option_case")
if selected_case:
st.success(f"You selected: {selected_case}")
col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8 = st.columns([2.3, 0.3, 2.3, 0.3, 2.3, 0.3, 2.3, 4.9])
if col_1.button("Original documents", key="view_document", use_container_width=True) or st.session_state.selected_document_prev:
document_options = ["document 0001.pdf", "test.mp4", "output_audio.wav", "Prop.pdf"]
selected_document = st.selectbox(
"**Select a document**",
document_options,
key="selected_document_prev")
if selected_document:
st.success(f"You selected: {selected_document}") # Debugging: show selected document
if col_3.button("Reports", key="update_lists", use_container_width=True):
if 'selected_document_prev' in st.session_state:
del st.session_state.selected_document_prev # Remove document selection when 'Reports' is clicked
st.write("**Summary**")
pdf_text = """Noii."""
st.text_area(" ", pdf_text, height=300, key="Summary-Text")
if col_5.button("Analysis", key="tests-stage", use_container_width=True):
if 'selected_document_prev' in st.session_state:
del st.session_state.selected_document_prev # Remove document selection when 'Analysis' is clicked
st.write("**Conv**")
pdf_text = """ ....."""
st.text_area(" ", pdf_text, height=300, key="Convergences-Text")
if __name__ == "__main__":
list_docs()