Skip to content

Instantly share code, notes, and snippets.

@derekstavis
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save derekstavis/1f7bbe9c16541b850d3d to your computer and use it in GitHub Desktop.

Select an option

Save derekstavis/1f7bbe9c16541b850d3d to your computer and use it in GitHub Desktop.
Kivy Clock performance with and without input enabled
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from sys import exit
from kivy.app import runTouchApp
from kivy.uix.widget import Widget
from kivy.clock import Clock
from time import clock
class Events(Widget):
trigger = None
t = clock()
def __init__(self, priority=False, **kwargs):
super(Events, self).__init__(**kwargs)
Clock.schedule_once(lambda dt: exit(0), 10)
self.trigger = Clock.create_trigger(self.callback, timeout=0.001)
self.trigger()
def callback(self, *l):
t = clock()
print 1 / (t - self.t)
self.t = t
self.trigger()
runTouchApp(Events())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment