python - 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 It goes on and on if we keep toggling How can we get rid of it?
解决方案
推荐阅读
- maven - 多模块项目中的 Spring Boot AOP 不执行之前的建议
- java - Java - 使用递归填充其他列表作为函数参数的列表值
- reactjs - 将 validator.js 与 ReactJS 一起使用的方法?
- database - 使用少量资源接收流数据的扩展数据库
- python-3.x - 在不打扰用户的情况下预选打印机和打印机属性
- python-3.x - 我怎么知道我的张量流结构是否适合我的问题?
- azure - 查看 Azure Blob 中存储的图像
- macos - 触发 cmd + shift + a 后出现奇怪的弹出窗口
- html - 如何将计数器的结果放入 html 页面顶部的卡片中?
- python - 如何垂直并排打印两个字符串