I am facing a problem in Tkinter python. my code is below:
cycles = 0
def send_it():
now = datetime.now()
print(now.strftime("%Y-%m-%d %H:%M:%S"))
time.sleep(1)
def send_me():
with keyboard.Listener(on_press=on_press) as listener:
global cycles
if(radio_var.get() == 1):
if cycles <= 3:
send_it()
cycles = cycles+1
elif(cycles == 4):
print("Done!")
break
elif(radio_var.get() == 2):
print("No!")
listener.join()
def order_schedule():
#Scheduling order send time
schedule.every().day.at("20:00:00).do(send_me)
while True:
schedule.run_pending()
time.sleep(2)
the problem is that although my job(send_me)
which is scheduled to be done every day at 20:00:00, stops when cycles == 4
, but after that Tkinter will be locked and I can't do anything for that. it took me many hours to figure out how to solve it but wasn't lucky.
I tried many things like return schedule.CancleJobs
and schedule.clear()
, also I tried to use threading but I was not able to do what I want.
hope you guys can help me get to the answer.
Thanks a lot