from streamlit.source_util import _on_pages_changed, get_pages # Adapted from https://discuss.streamlit.io/t/how-to-hide-all-pages-before-login/32508 # Note this code is intended to remove pages at app load time, not based on login SEASON_MODE = "season" OFFSEASON_MODE = "offseason" CURRENT_MODE = SEASON_MODE MAIN_PAGE_FILE = "Home.py" MODE_PAGE_EXCLUSION_MAP = { SEASON_MODE: [ "Keepers", "ECR", ], OFFSEASON_MODE: ["Practice_Reports"], } def remove_seasonal_pages(): all_pages = get_pages(MAIN_PAGE_FILE) pages_to_remove = MODE_PAGE_EXCLUSION_MAP[CURRENT_MODE] page_keys_to_remove = [] for k, v in all_pages.items(): if v["page_name"] in pages_to_remove: page_keys_to_remove.append(k) for k_remove in page_keys_to_remove: del all_pages[k_remove] _on_pages_changed.send()