Set_page_config not working with spinner

I’m not sure if this is a bug or I’m using something incorrectly.

I have an app that uses the navigation methods here: https://docs.streamlit.io/develop/api-reference/navigation/st.navigation. I have a main.py file and then additional files for each page. Within main, I use st.set_page_config to change the page_title, page_icon and layout.

Within one of the pages, I have st.spinner since I have an operation that takes awhile to run. I noticed that when it is running, the tab in my browser reverts back to saying “Streamlit” and showing the default Streamlit icon.

I would definitely prefer if it kept my page_title and page_icon the same, so I’m wondering if this is the intended behavior or a bug/something overlooked.

Hi @msquaredds,

Can you give a simple reproducible snippet that shows the issue? This is what I’m trying, but I don’t see that behavior in my browser.

app1.py

import streamlit as st

pages = [
    st.Page("app1b.py", title="Home"),
    st.Page("app1c.py", title="About"),
]

page = st.navigation(pages)

st.set_page_config(page_title=page.title)

page.run()

app1b.py

import time

import streamlit as st

st.title("Home Page")

with st.spinner():
    time.sleep(3)

Ok, so when setting up a toy example, it looks like this behavior is only happening on Google Cloud Run, which is where I am running my other project. I tried it on Streamlit.io and wasn’t getting the same behavior

However, I also discovered that it only happens when the spinner is within a button and not just on its own

For what it’s worth, I usually run on Chrome, but I tried it in Edge and am getting the same behavior there too

I have a GitHub repo here: https://github.com/msquaredds/BrowserTabTest/tree/master

  • This will show the two python files, which are largely the same as your example but with the button added, plus a reqs file and Dockerfile

And test website here: https://browsertabtest-1057020357347.us-central1.run.app/

I don’t think you’re doing anything wrong, it’s just a side-effect of the way callbacks work – they run before everything else on the page, in this case including st.set_page_config. I don’t know of anything besides not doing the st.spinner in a callback, unfortunately. I’m not sure, but streamlit.io might be doing something special to cache the name and icon so that it avoids this issue.

I see, that generally makes sense, thanks

I might open a request on github since it would be nice to keep the page title and icon regardless of where it’s hosted

I’m also trying to think of possible workarounds, but haven’t come up with anything yet

1 Like

As of Streamlit version 1.46.0, you can call st.set_page_configuration multiple times in the same script run. So you can call st.set_page_config at the beginning of your callback function where needed.

I can think of two ways to access the page title within a callback:

  1. Dig into the internals of Streamlit to pull out the page title from the current script context/page manager (a little messy).
  2. Save the page title into Session State, updating immediately after st.navigation in your entrypoint file so that it’s available to your callback functions.

Oh nice, being able to call set_page_config again is awesome! That worked for me!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.