如何使用 Kivy 安排活动 Clock.schedule_once

How to schedule event with Kivy Clock.schedule_once

运行后Label.text同时为1。我需要从 10 到 1 倒计时,暂停 1 秒。

from kivy.app import App
from kivy.uix.label import Label
from kivy.clock import Clock

from functools import partial

class DurationClock(Label):
    def update(self, index, *args):
        self.text = index

class TimeApp(App):
    def build(self):
        durclock = DurationClock()
        for i in range(10, 0, -1):
            Clock.schedule_once(partial(durclock.update, str(i)), 1)
        return durclock

if __name__ == "__main__":
    TimeApp().run()

在回调中展开计划时间:

Clock.schedule_once(partial(durclock.update, str(i)), 10-i)

现在,他们都被安排在同一时间。