my code like this:
# File : main.py
import streamlit as st
if __name__ == "__main__":
st.set_page_config(layout="wide")
st.markdown(
"""
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
""",
unsafe_allow_html=True
)
pg = st.navigation(
[
st.Page("st_pages/page_1.py", title="**Page1**", url_path="Summarize"),
st.Page("st_pages/page_2.py", title="**Page2**", url_path="Search", default=False),
st.Page("st_pages/page_3.py", title="**Page3**", url_path="Detail", default=False),
],
position="hidden"
)
with st.sidebar:
st.radio("What's your name?", ("**A**", "**B**"),
label_visibility="collapsed", key="r_value", index=0)
display_project = st.session_state.get("r_value", "**Demo**")
st.caption(f"Current Value::green[{display_project}]")
st.divider()
st.page_link("st_pages/page_1.py", label="**Page1**")
st.page_link("st_pages/page_3.py", label="**Page3**")
st.divider()
pg.run()```
File : st_pages/page_1.py
import streamlit as st
if name == ‘page’:
btn = st.button(“Switch”)
if btn:
st.switch_page(“st_pages/page_2.py”)
File : st_pages/page_2.py
import streamlit as st
if name == ‘page’:
st.write(“Current Page: page_2”)
When I set radio value then switch page, the radio value change to default value. How can I reslove this problem?