I'm reading through the official PyGObject tutorial, and I found this (unexplained) line in one of the examples:
self.timeout_id = None
(it was within an __init__
function of a Gtk.Window
-descendant class; the whole listing is here). I couldn't google it; what is it for?
You didn't see it being set and used further down in on_pulse_toggled ?
It is assigned the return value of GObject.timeout_add, which adds a function to be called at a later interval, possibly repeatedly (like in this case):
self.timeout_id = GObject.timeout_add(100, self.do_pulse, None)
When you want this timeout not be called anymore, you have to remove it, and to do so, you need the id of the timeout you created:
GObject.source_remove(self.timeout_id)