首页 > 解决方案 > Streamlit Multiple Page UI - Page content retaining on using sliders

问题描述

I am creating multipage streamlit ui… In one page I have the option to upload File only In another page there are 10 slider buttons. The user should be able to move around the pages… When the user moves from one page to another, the contents of page1 which has 10 sliders are getting copied in the background… is there any way I could get fresh Page when the user toggles between the pages…</p>

main_app.py

import app1
import app2
import streamlit as st
PAGES = {
"Page 1": app1,
"Page 2": app2
}
st.sidebar.title('Navigation')
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
page = PAGES[selection]
page.app()

app1.py

import streamlit as st
def app():
   st.empty()
   st.title('APP1')
   st.write('Welcome to app1')
   for i in range(10):
      st.slider("Helpful ?", 1, 5, key = str(i))
   return

app2.py

import streamlit as st
def app():
   st.empty()
   st.title('Welcome to App2')
   uploaded_file = st.file_uploader("Upload New File")

On alternate Toggling between Page 1 > Page 2 > Page 1 > Page 2. Below is how UI looks Output after Toggling in above sequence.. It goes on and on if we keep toggling How can we get rid of it?

标签: pythonhtmluser-interfacedata-sciencestreamlit

解决方案


推荐阅读