python - 执行功能后 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.CancleJobs
and schedule.clear()
,我也尝试使用线程,但我无法做我想做的事。
希望你们能帮助我得到答案。
非常感谢
解决方案
推荐阅读
- python - Teradatasql python 有问题
- java - 用于将文件上传到服务器上的文件夹的 Ajax 调用返回 403 错误
- android - 这里不允许使用属性 android:hardwareAccelerated
- ios - iOS 表格/列表中的粘滞菜单
- python - 使用正则表达式验证用户输入
- mysql - 更新 mysql/mariadb 表时发送电子邮件的清洁、低开销方式?
- python - Django - 如何将过滤后的查询集传递给 Detailview
- node.js - 如何在 Node 和 ESM 中使用代理?
- c# - 阻止用户在使用 Azure AD 登录后访问特定页面
- reactjs - React 不会按预期创建新的嵌套组件