首页 > 解决方案 > 执行功能后 tkinter 锁定

问题描述

我在 Tkinter python 中遇到问题。我的代码如下:

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) 

问题是,虽然我的工作(send_me)计划在每天 20:00:00 完成cycles == 4,但在 我花了好几个小时才弄清楚如何解决它,但并不幸运。

我尝试了很多事情,比如return schedule.CancleJobsand schedule.clear(),我也尝试使用线程,但我无法做我想做的事。

希望你们能帮助我得到答案。

非常感谢

标签: pythontkinter

解决方案


推荐阅读