Getting clock schedule to start in python kivy app

Viewed 15

I can't figure out what's wrong with my code. I've tried several variations, and I can't get Clock to schedule the function12. Please help. Thank you!

import os
os.environ["KIVY_NO_CONSOLELOG"] = "1"
from kivy.app import App
import time
from kivy.clock import Clock

class MainApp(App):

    def on_start(self):
        print("Here")
        Clock.schedule_once(self.function12,5)
        print("Here")
        time.sleep(100)

    def function12(self):
        print("INSIDE")
1 Answers

Your function12() method needs a dt argument, like this:

def function12(self, dt):
    print("INSIDE")

And the scheduled method cannot run until the time.sleep() has completed, since the on_start() method is running on the main thread, and the sleep holds the main thread.

Related