Reputation: 271
After run Label.text is 1 at same time. I need countdown from 10 to 1 with 1 sec pause.
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()
Upvotes: 3
Views: 9634
Reputation: 2016
Spread the schedule time in the callback:
Clock.schedule_once(partial(durclock.update, str(i)), 10-i)
Right now, they are all scheduled at the same time.
Upvotes: 4