Changing "pages" with the click of a button

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
1 Like

Are you trying to accomplish pagination?
Example of what I mean:

So here you just have several list items generated( in your case it may be plots)

Hi @conic,

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.

Hi. Have you found an answer to your question?

Hi @Emmanuel_Pean,

I have made a bit of a hack that on the most part will do what you ask, its on the thread: Navigation panel - can we have a button on the right hand side like 'Next' which automatically moves to the next 'page' in the navigation panel

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

Happy Streamlit-ing!
Marisa