我有这个秒表,我试图在计数达到 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/