Im switching pages by declaring a session_state[“page”] variable in Streamlit. There are 3 pages: landingpage, dashboard, settings. By clicking on a button the session_state gets updated and the corresponding function gets called in order to fill the pages content:
Content of the functions “navigate_landingpage()”, “navigate_dashboard()”, “navigate_settings()” are just basic Streamlit functionalities.
Expected behavior:
Just showing content of the corresponding function.
Actual behavior:
Depending from which page Im switchting to “dashboard” everytime a part of the content of “landingpage” or “settings” are also shown on the bottom of the reloaded page.
Additional information
Im dealing with this behaviour since I added a while True function for calulations into the “dashboard” page. By switching from “settings” page into “landingpage” page, everything is normal, only problems by switching into or from “dashboard” page!
Thanks for the quick reply! I dont have any problems by switching pages. The only thing is that some part of the previous page are also displayed in addition to the selected page.
Ah, I see. Is the “while true” entirely necessary? I have seen that cause issues before with old pieces of UI still showing up blurred. Can you share a reproducible code snippet which shows this behavior?
Also, on a side note, have you considered using the built-in multipage app feature, rather than manually handling page switching?
Yes the “while true” is necessary in order to get new data and update the plots continuously…
the main loop looks like:
while True:
data = get_fresh_data()
for idx, obj_x in enumerate(station_list):
status = get_alarm_status(data, obj_x)
if obj_x == "Quick Stats":
metrics_obj = get_metrics_data(data)
else:
metrics_obj = None
fig = build_figure(data, obj_x)
if status == 'ok':
fill_reaction_obj(reaction_obj, idx, "ok")
else:
fill_reaction_obj(reaction_obj, idx, "nok", ["Here you can advertise :)", "Here you can advertise :)", "Here you can advertise :)"])
fill_monitoring_obj(monitor_obj, idx, metrics_obj, status, fig)
time.sleep(st.session_state["refresh_rate"])
For the navigation Iam using the on_hover_tabs component:
For this i set the key to page in order to switch between the pages.
When I am doing only one iteration instead of the “while True”, the blurred area disappears in some seconds…
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.