Here is a simple example I helped another user with that shows how to use Clock.schedule_interval. You can use Clock.schedule_once the same way. Code attached.
class SimClock(Label):
current_time = StringProperty(strftime('%H:%M:%S'))
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.timer = Clock.schedule_interval(self.update_time, 1)
def update_time(self, dt):
self.current_time = strftime('%H:%M:%S')
def cancel_time(self):
self.timer.cancel()
There is a class SimClock derived from a label. When the class is constructed, the schedule is started.
Once a second update_time() is called. It reads the current time and updates the value on the label, using the string property current time.
Looking at part of the KV code…
ImageButton:
size_hint_x: 1
size_hint_y: 0.8
source: './clock.jpeg'
on_release:
mylabel.cancel_time()
self.source = './play.png'
mylabel.text = 'wakey wakey eggs and beaky'
When the mouse button is released on the clock image, the cancel_time() method is called, stopping the schedule.
--
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/46de4ef8-1b89-4b64-89bb-b589dbf1f4b8%40googlegroups.com.