gpt4 book ai didi

python - Tkinter:root.after(), root.after_cancel()

转载 作者:太空宇宙 更新时间:2023-11-04 06:40:44 27 4
gpt4 key购买 nike

我有这个秒表,我试图在计数达到 0 后重置它。但是我在使用“after_cancel”功能时遇到了问题。谁能帮忙?
发生的是它无休止地继续,我想杀死“之后”功能。

def countdown(self):
if self.totalseconds == 1:
self.master.after_cancel(self.after_id)
self.totalseconds = self.totalseconds - 1
stdtime = self.total_seconds_to_standard(self.totalseconds)
self.time.set(stdtime)
self.after_id = self.master.after(1000,self.countdown)

最佳答案

想通了……foobar。

def countdown(self):
self.totalseconds = self.totalseconds - 1
stdtime = self.total_seconds_to_standard(self.totalseconds)
self.time.set(stdtime)
self.after_id = self.master.after(1000,self.countdown)
if self.totalseconds == 0:
self.master.after_cancel(self.after_id)

关于python - Tkinter:root.after(), root.after_cancel(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52031267/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com