为什么我的 Streamlit 应用程序会打开多次?
Why does my Streamlit application open multiple times?
我正在尝试使用
启动 Streamlit 应用程序
import os
os.popen("streamlit run stockXchange.py")
当我运行这段代码时,会出现无数个流光windows,每隔3秒左右弹出一个接一个。阻止这些 windows 弹出的唯一方法是完全关闭输出 window。 (我正在使用 PyCharm)
这是我的代码:
import os
import streamlit as st
class Streamlit:
def __init__(self):
Streamlit.setup()
def setup(self):
st.title("StockXchange GUI")
query = st.text_input("Enter company name:")
if st.button("Go"):
#calls the application function
load(query)
if __name__ == "__main__":
print(starttext)
print(os.popen("streamlit run stockXchange.py").read())
#Workaround 'missing 1 required positional argument: 'self'' Error
Streamlit.setup(Streamlit)
我希望只弹出一个 window,而不是无限多的 windows。
有什么办法可以解决这个问题吗?
使用 Streamlit,您无需为 运行 您的 Streamlit 应用程序创建 class 包装器。
假设您的 stockXchange.py
是 streamlit 应用程序,那么它应该是来自命令行的 运行 或 from the PyCharm console 像这样:
streamlit run stockXchange.py
您 class 中的所有以下行都应该进入该文件:
st.title("StockXchange GUI")
query = st.text_input("Enter company name:")
if st.button("Go"):
#the rest of stockXchange.py pertaining to the query
您获得无限流光的原因 windows 是因为以下行在程序执行方面创建了一个无限循环:
if __name__ == "__main__":
os.popen("streamlit run stockXchange.py")
我正在尝试使用
启动 Streamlit 应用程序import os
os.popen("streamlit run stockXchange.py")
当我运行这段代码时,会出现无数个流光windows,每隔3秒左右弹出一个接一个。阻止这些 windows 弹出的唯一方法是完全关闭输出 window。 (我正在使用 PyCharm)
这是我的代码:
import os
import streamlit as st
class Streamlit:
def __init__(self):
Streamlit.setup()
def setup(self):
st.title("StockXchange GUI")
query = st.text_input("Enter company name:")
if st.button("Go"):
#calls the application function
load(query)
if __name__ == "__main__":
print(starttext)
print(os.popen("streamlit run stockXchange.py").read())
#Workaround 'missing 1 required positional argument: 'self'' Error
Streamlit.setup(Streamlit)
我希望只弹出一个 window,而不是无限多的 windows。
有什么办法可以解决这个问题吗?
使用 Streamlit,您无需为 运行 您的 Streamlit 应用程序创建 class 包装器。
假设您的 stockXchange.py
是 streamlit 应用程序,那么它应该是来自命令行的 运行 或 from the PyCharm console 像这样:
streamlit run stockXchange.py
您 class 中的所有以下行都应该进入该文件:
st.title("StockXchange GUI")
query = st.text_input("Enter company name:")
if st.button("Go"):
#the rest of stockXchange.py pertaining to the query
您获得无限流光的原因 windows 是因为以下行在程序执行方面创建了一个无限循环:
if __name__ == "__main__":
os.popen("streamlit run stockXchange.py")