I would like to know if there is a way to hide some pages using the streamlit multipage. For example, I create a condition to show page1 and page2, in another situation I only show in the side bar page3 and page4…
5 Likes
I don’t think so but I’d really like this feature too.
This can easily be achieved with the old streamlit options menu library (GitHub - victoryhb/streamlit-option-menu). Also powerful when combined with the old multipage module . I honestly don’t like the native integration of multipage.
Let’s pretend you wanna show different menus if a user is logged in or not.
import streamlit as st
from streamlit_option_menu import option_menu
### Import what to render if a user is not logged in:
from public_pages.render_home_page import home
### import stuff to render if a user IS logged in
from privat_pages.display_user_stats import display_user_stats
from privat_pages.display_user_models import display_user_models
if 'user_authenticated' not in st.session_state:
with st.sidebar:
menu_selection = options_menu["Home","About us","Login"]
if menu_selection == "Home":
home()
**if 'user_authenticated' in st.session_state:**
with st.sidebar:
menu_selection = options_menu["My stats","My models","Account Settings"]
if menu_selection == "My stats":
display_user_stats(user)
if menu_selection == "My models":
display_user_models(user)
1 Like