How do I make ClockClock.schedule_once () run multiple times at different intervals?

22 views
Skip to first unread message

ТН Н

unread,
Feb 4, 2021, 12:56:46 PM2/4/21
to Kivy users support
I have a code where I want to pass ClockClock.schedule_once () a lot of intervals. For example, first it will start the function after 2 minutes, then after 5 minutes, and then after 10. How do I implement this? The problem is that it alternately gets time intervals and only the last one is triggered.

Elliot Garbus

unread,
Feb 4, 2021, 2:07:04 PM2/4/21
to kivy-...@googlegroups.com

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.

 

Esmail Raweh

unread,
Feb 4, 2021, 2:51:25 PM2/4/21
to kivy-...@googlegroups.com
Can you help me how install package kivy in qpython 3L in my phone? 

ТН Н

unread,
Feb 4, 2021, 3:16:50 PM2/4/21
to Kivy users support
Thank you very much!

четверг, 4 февраля 2021 г., 22:07:04 UTC+3 пользователь ElliotG написал:

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Feb 4, 2021, 3:50:40 PM2/4/21
to kivy-...@googlegroups.com
I can not. You may want to create a new thread and ask. 
I would be surprised if you could install kivy on that kind of platform. Kivy includes a number of binary dependencies. 

Sent from my iPhone

On Feb 4, 2021, at 12:51 PM, Esmail Raweh <esmail...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages