I’m working on Visual Studio Code, I have been working on a app. Until this moment in looks like:
By default the .py files in which I create the app are show in the sidebar, but I just want to see “Inicio” and under this I want to create a select_box that contain the years and allow me to surf into that pages (years in this case) . I don’t want to see 2013,2014 as well.
I’ve tried some options but those are shown under the image you see.
How can I fix that??
Thk u!
You can do this by disabling the normal page list in the sidebar by creating a file called .streamlit/config.toml
that looks like this streamlit-login/.streamlit/config.toml at main · blackary/streamlit-login · GitHub
Once you’ve done that, you can add whatever you want to add in the sidebar, like this:
import streamlit as st
def switch_page():
year = st.session_state.year
st.switch_page(f"pages/{year}.py")
st.sidebar.page_link("pages/incio.py", label="Incio")
st.sidebar.selectbox("Year", ["2013", "2014"], on_change=switch_page, key="year")
You can also take a look at this example New login page navigation example with streamlit 1.31 for a more complex custom sidebar
Hi!
Your answer has been useful. By the way when I try to get into new pages, the information doesn’t appear.
Can u help me???
Thk u!!
Sorry, I should have mentioned – if you use that method, you have to run that code that I shared on every page.
If you look at my example here, you can see that I made a function called “make_sidebar” and I then call that on every page, which is a nice way to do it without repeating yourself too much.