First post here so forgive me if I botch this…
I’m using st-pages
(love it!) and many of my pages make st.radio
calls to select data. When I make a selection, no matter the page, I change the corresponding st.session_state
variable and my widgets all update immediately, including those in the sidebar.
The problem I am having… even though all the “widgets” update, my st-pages
“dynamic” menu does not.
To build/display that menu I’ve defined a menu( )
function as:
# menu( ) - Build and display the dynamic page menu in the sidebar
# --------------------------------------------------------------------------------------
def menu(top_of_page=True):
pages = [ Page("main.py", "Home", "🏠"),
Page("login.py", "Login to OBFUSCATED.com", "💪"),
Section(name="Load Waypoints", icon=":pushpin:"),
Page("load_gpx.py", "From a GPX File", ":open_file_folder:"),
Page("query.py", "Query OBFUSCATED.com", ":question:" ),
Section(name="Visualize Data", icon=":bar_chart:"),
Page("map_waypoints.py", "Map Waypoints", ":world_map:") ]
if not state('loaded'):
hide_pages( ["Visualize Data", "Map Waypoints"] )
if not state('connected'):
hide_pages( ["Query OBFUSCATED.com"] )
show_pages(pages)
if top_of_page:
add_page_title( ) # necessary for proper menu indentation
return
My state( ) function is just shorthand to return an st.session_state variable. I call menu( )
at the top of every page, and tried callingmenu(False)
at the bottom of every page, but that didn’t help with my problem.
I suspect I’m missing something simple here, or maybe my design isn’t what it should be. Anyone have a suggestion?