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.