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.
Just showing content of the corresponding function.
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.
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!
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:
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)
metrics_obj = None
fig = build_figure(data, obj_x)
if status == 'ok':
fill_reaction_obj(reaction_obj, idx, "ok")
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)
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…