Hello, I’m currently developing a Multipage App to showcase real-time data. However, I’ve encountered an issue when transitioning from page 1 to page 2 where the data from page 1 persists in the background, causing an overlap as depicted in the attached screenshot.
Page1:
Page2:
I have included both page 1 and page 2 code along with the corresponding CSV file for page 1.
Page1.py:
import streamlit as st
import pandas as pd
# Set page configuration
st.set_page_config(page_title="gNB Configurations", layout="wide")
# Function to read L1 cfg CSV file and display its content
def load_L1_Param(global_L1_Param):
return pd.read_csv(global_L1_Param)
# Function to display L1 CFG
def display_L1_Param(df1):
# Display header
st.subheader(" ")
# st.subheader("Page 1 Data")
st.title("Display From Page 1")
# Display headers as columns
headers = ['CELL_ID', 'VF0', 'VF1', 'RU_MAC', 'NUMBER OF RU', 'FEC MODE', 'HW FEC ADDR','NUMBER OF CELLS']
columns = st.columns(9)
for i, header in enumerate(headers):
columns[i].write(header)
# Display data as columns
for index, row in df1.iterrows():
values = [row['CELL_ID'], row['VF0'], row['VF1'], row['RU_MAC'], row['NUMBER OF RU'], row['FEC MODE'],row['HW FEC ADDR'], row['NUMBER OF CELLS']]
for i, value in enumerate(values):
columns[i].write(value)
# Main function
def main():
# Title
# st.title("Display CSV Data")
# Path to local CSV file
global_L1_Param = "global_l1_cfg.csv"
# Load CSV data
df1 = load_L1_Param(global_L1_Param)
# Button to refresh data
if st.button("Refresh Data"):
# Reload CSV data
df1 = load_L1_Param(global_L1_Param)
# Display updated CSV data
# display_L1_Param(df1)
st.title("Display From Page 2")
st.rerun() # Rerun the script to update content in-place
# Display CSV data
display_L1_Param(df1)
if __name__ == "__main__":
main()
global_l1_cfg.csv looks like the below table
Page2.py
import streamlit as st
import time
# Set page configuration
st.set_page_config(page_title="Live KPI Metrics", layout="wide")
# "---"
# st.subheader('L1 KPIs', divider='rainbow')
# "---"
def l1_kpi():
st.title("Display From Page 2")
while True:
l1_kpi() # Display metrics with live data
time.sleep(5) # Wait for 2 seconds before updating again
# st.empty() # Rerun the script to update content in-place
st.rerun() # Rerun the script to update content in-place
I would greatly appreciate any suggestions or solutions to resolve this issue. Please note that I prefer not to utilize caching. Thank you.
- Are you running your app locally or is it deployed? >> Locally
- Share the Streamlit and Python versions. >> Streamlit, version 1.31.1 and Python 3.8