[英]How to switch page on button click using Streamlit?
I have made separate functions for each page, but i want to change page to file upload when I click button on welcome_page.py.我为每个页面制作了单独的功能,但我想在单击 welcome_page.py 上的按钮时将页面更改为文件上传。 Found a switch_page function but I don't think I understand how it works.找到了 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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.