Search code examples
kivyclock

cancel ALL kivy clocks from seperate file


in my kivy app , i have around 15 modules and *.kv files. In a couple of those files i have started a clock with for example this clock event that triggers every 5 minutes

self.updating_my_coordinates = Clock.schedule_once(self.trigger_database_update, 300)

When i "log out" of the app from a logout button in a seperate module to the clock code, it takes me to the sign in screen, but i notice in the console the active clock events are still triggering. So my question is... How do i cancel ALL active clocks in a kivy app from a method in a seperate module to where the clocks originate from ?

Obviously calling self.updating_my_coordinates.cancel() from the logout modules method fails cause there is no self.updating_my_coordinates

also tried

Clock.unschedule(all=True)

but that requires 1 positional arg

My brains failing to understand the document at https://kivy.org/doc/stable/api-kivy.clock.html for this situation and would like some advise please


Solution

  • To answer my own question

    Now that i'm a little more familiar with the operations of kivy.....In the end, the way i cancelled a clock from a different screen was simply do a

    App.get_running_app().root.get_screen("screen_name").cancelClock()

    then added

    def cancelClock(self):
        Clock.unschedule(updating_my_coordinates)
    

    Where "screenName" is the screen that the event was started from and updating_my_coordinates is the name of the event

    right or wrong, it worked :) hope that helps another newbie one day