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()
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With