You could create a list of intervals as a local list to the method that is calling Clock.schedule_once()
Create an instance variable used to access the list. Increment the list every time the method is called.
from kivy.app import App
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.uix.label import Label
kv = """
BoxLayout:
WaitLabel:
font_size: 30
"""
class WaitLabel(Label):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.wait_index = 0
self.waits = [1, 2, 3, 1, 5, 2]
def on_kv_post(self, base_widget):
self.wait(0)
def wait(self, _):
self.text = f'Wait time: {self.waits[self.wait_index]} seconds'
Clock.schedule_once(self.wait, self.waits[self.wait_index])
self.wait_index = (self.wait_index + 1) % len(self.waits) # wrap in a circle
class WaitApp(App):
def build(self):
return Builder.load_string(kv)
WaitApp().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/bb953d89-845f-44f6-be08-6d6950faab6ao%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/601c45d1.1c69fb81.76419.3ee9SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
On Feb 4, 2021, at 12:51 PM, Esmail Raweh <esmail...@gmail.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGjrqH7yXt%3D-eWz-PLo32yasV6Fv1u7ZDYitczhsazoMTEsehA%40mail.gmail.com.