python - 如果触发了某个标志,我想停止一个方法而不完成它的指令
问题描述
我有一个每隔几秒钟显示一个顶层窗口的方法,无论如何,如果用户单击关闭按钮而不是确定按钮,则不应显示剩余的顶层窗口。在下面的代码中 disAction() 是关闭按钮的命令
我尝试使用 while 循环,它显示“未响应”错误
def topRequester(self):
if self.dismiss == 0:
self.after(SLEEP_SEC, self.toplevelmaker)
self.after(SLEEP_SEC + SLEEP_SEC, self.toplevelmaker)
self.after(SLEEP_SEC + SLEEP_SEC*2, self.toplevelmaker)
self.after(SLEEP_SEC + SLEEP_SEC*2, self.topRequester)
def disAction(self): # the cycle should be disrupted
self.topwin.withdraw()
self.dismiss = 1
解决方案
推荐阅读
- html - 显示 Angular 4 和另一个切片中选定的切换按钮
- c++ - 在 IF 语句中调用函数与不在 IF 语句中调用函数
- php - 扩展抽象测试类时找不到测试类
- c# - 哪个参考和对象是什么意思以及如何解决?
- excel - 应用公式,从选定单元格偏移三列
- android - 为什么显示空数据?
- selenium - 错误:gpu_process_transportfactory.cc(1`017) 丢失 UI 共享上下文与非无头 chrome
- c++ - C ++ FFmpeg如何在刷新后继续编码?
- sql - 如何获取具有当前行 ID 的子查询?
- css - 如果我有标签的 CSS 文件,如何更改 1 个特定标签字体的大小?