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
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.