My streamlit app starts on the “About” section where details are given about to use the app.
I created another “page” where I want to display figures and plots. Both “pages” can be selected using a simple selectbox.
I would like that when clicking on a specific button, the app switch to the second “page”. Is there any way to do that?
import streamlit as st
page = st.selectbox('Page', ('About', 'Plot'), 0)
if page == 'About':
st.info('test')
button = st.button('button')
if button:
page = 'Plot' # does not work
I don’t need to keep all the plots in different pages.
Once the button is clicked, the last plot is replaced by the new plot in the “Plot” page (hope that makes sense).
Basically, if you run the code of my post, I would like that the selectbox switch to ‘Plot’ when the button is clicked.
The real way to do this is through session state, that is to get the state of the app at a certain point and be able to increment or change this based on a click that the user does. Here is a link to using session state workarounds: Multi-page app with session state