I'm using the nifty Kivy framework to program a game for Android. I'm trying to create a clock callback to run a specified piece of code (used to draw) 60 times a second.
For some reason, anything I draw inside of a Kivy clock event doesn't get drawn to the screen. To eliminate all variables I could, I took this sample code:
import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color, Ellipse
class MyPaintWidget(Widget):
def on_touch_down(self, touch):
with self.canvas:
Color(1, 1, 0)
d = 30.
Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d))
class MyPaintApp(App):
def build(self):
return MyPaintWidget()
if __name__ == '__main__':
MyPaintApp().run()
This works fine - when I click on the screen it puts a yellow circle there. However, when I modify it like this:
import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color, Ellipse
from kivy.clock import Clock
class MyPaintWidget(Widget):
def update(self, t):
with self.canvas:
Color(1, 1, 0)
d = 30.
Ellipse(pos=(200 - d/2, 200 - d/2), size=(d, d))
class MyPaintApp(App):
def build(self):
m = MyPaintWidget()
Clock.schedule_interval(m.update, 1.)
return m
if __name__ == '__main__':
MyPaintApp().run()
Nothing is ever drawn to the screen. Why? EDIT: I found out it only draws to the screen when I click it. Still not useful - I need to use this for a game's event loop! I am using Kivy 1.4.0 (the second most recent) and Ubuntu. This also doesn't work as intended on Android, either.