So I made this very simple tkinter python program
That where you enter start and stop time
and that works perfectly fine
If you reenter a new time
you will always get a
and have been unsuccessful here is my working program so far
That where you enter start and stop time
and that works perfectly fine
If you reenter a new time
you will always get a
Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\Python311\Lib\tkinter\__init__.py", line 1948, in __call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\Program Files\Python311\Lib\threading.py", line 952, in start raise RuntimeError("threads can only be started once") RuntimeError: threads can only be started onceI'm trying to figure out how to catch this error in a try block
and have been unsuccessful here is my working program so far
" import tkinter as tk import schedule import time import threading root = tk.Tk() root.title("MyApp") root.geometry("284x280+700+200") # Size of the window Start_Time1 = tk.StringVar() Stop_Time1 = tk.StringVar() def job(): print("I'm working...") # this is just for testing return schedule.CancelJob # remove it from the scheduler def time_up(): schedule.clear() print('time has elapsed') # this is just for testing time.sleep(2) # root.quit() # this seems to work here, close the window and the program def schedule_time(): print("working...") # this is just for testing schedule.every().day.at(Start_Time1.get()).do(job) # or you can place your times in here schedule.every().day.at(Stop_Time1.get()).do(time_up) # print("schedule_time", Start_Time.get()) # this is just for testing while True: # Checks whether a scheduled task # is pending to run or not schedule.run_pending() if not schedule.jobs: # this will stop after the last scheduled event break time.sleep(1) # root.destroy() # if you want the main window to be terminated # print("I'm done") # this is just for testing Message = tk.Label(root, text='Enter time as ( HH:MM )', font=('Arial', 12)) Message.place(x=50, y=10) Start = tk.Label(root, text='Start_Time:', font=('Arial', 12)) Start.place(x=18, y=50) text_entry = tk.Entry(root, width=8, textvariable=Start_Time1, font=('Arial bold', 12)) text_entry.place(x=116, y=50) # x = left to right y = top to down Stop = tk.Label(root, text='Stop_Time:', font=('Arial', 12)) Stop.place(x=18, y=90) text_entry = tk.Entry(root, width=8, textvariable=Stop_Time1, font=('Arial bold', 12)) text_entry.place(x=116, y=90) button1 = tk.Button(root, text="Start Time", font=('Arial', 12), command=threading.Thread(target=schedule_time).start) button1.place(x=50, y=125) root.mainloop()any help would be appreciated on trying to figure this out