[英]How to switch page on button click using Streamlit?
我为每个页面制作了单独的功能,但我想在单击 welcome_page.py 上的按钮时将页面更改为文件上传。 找到了 switch_page function 但我不明白它是如何工作的。
import streamlit as st
from login import check_password
from file_upload import file_upload
from welcome import welcome_page
from PIL import Image
from numpy import asarray
from streamlit_extras.switch_page_button import switch_page
def file_upload():
datafile = st.file_uploader("Upload JPG",type=['jpg'])
if datafile is not None:
numpydata = asarray(datafile)
print(type(numpydata))
st.image(datafile)
return True
return False
if check_password():
if welcome_page():
switch_page('file_upload')
fileDetails = file_upload()
if fileDetails:
print("file uploaded")
不幸的是,在 Streamlit 多页面应用程序中没有内置的方式来以编程方式切换页面。 如果您想投票,请在此处提出开放功能请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.