I am trying to start the Streamlit application using
import os
os.popen("streamlit run stockXchange.py")
When I run this code, there will be an infinite number of streamlit windows, popping up one after another every 3 or so seconds. The only way to stop these windows from popping up is by closing the output window completely. (I am using PyCharm)
Here is my code:
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)
I want there to only be one window popping up, not an infinite number of windows.
Is there any way to fix this?
Disadvantages of Streamlit Will not scale. Cannot easily customize any of the frontend components. Relatively new, so there are features that are still beta. Since it's relatively new, sometimes it's hard to find answers to your questions.
Streamlit is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science. In just a few minutes you can build and deploy powerful data apps. So let's get started!
With Streamlit you don't need to create a class wrapper to run your Streamlit application.
Presuming that your stockXchange.py
is the streamlit app, then it should be run from the command line or from the PyCharm console like so:
streamlit run stockXchange.py
All of the following lines from your class should go into that file:
st.title("StockXchange GUI")
query = st.text_input("Enter company name:")
if st.button("Go"):
#the rest of stockXchange.py pertaining to the query
The reason you're getting unlimited streamlit windows is that the following line creates an infinite loop in terms of program execution:
if __name__ == "__main__":
os.popen("streamlit run stockXchange.py")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With