import streamlit as ST
from datetime import datetime as DT
from multiprocessing import Process
import os
import time
import signal
def main():
ST.subheader(“My Process”)
while ST.checkbox(“Start_Button”)==True:
ST.write(“process is running”)
if name == ‘main’:
main()
When I run it using the normal streamlit run MyApp.py I get this error " There are multiple identical st.2601830728040438005 widgets with the same generated key." on the while checkbox line. Is there way to construct a loop that runs while a streamlit checkbox is ticked? Has anyone done something similar?
As I explained in the previous email, I want a piece of code to keep looping while the checkbox is ticked. I am basically writing an app that pulls exchange rates on a real time basis every minute. If I replace the while with an “if” statement, the code executes once and stops. I want it to repeat over and over again while the checkbox in my example is ticked. The ST.write(“process is running”) should be replace with a sub routine called My_Process() that runs the code over and over again.
def My_Process():
.
.
.
while ST.checkbox(“Start_Button”)==True:
My_Process()
I tried that. Streamlit gets stuck in the while loop, unfortunately. It means once you enter the loop, you cannot get out of it - not even using a threading.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.