Am I missing something important in this code? Running the following
script produces a window with a translucent 40x40 Rectangle in the
lower left corner ( as in with x=0, y=0 even though I set "center =
(100,100)" ). The Animation "happens" (as in the GoStone updates
its .pos), but no motion is visible on the screen - the Rectangle just
sits in the lower-left corner.
I am able to run all of the scripts in the kivy examples folder and
they work fine. What's wrong with my script?
Thanks,
Dean
import kivy
from
kivy.app import App
from kivy.graphics import Color, Rectangle
from kivy.uix.widget import Widget
from kivy.animation import Animation
from kivy.clock import Clock
class GoGame(Widget):
def __init__(self, **kwargs):
super(GoGame, self).__init__(**kwargs)
self.stone = GoStone(size=(40,40))
self.stone_info()
self.stone.center = (100,100)
self.stone_info()
anim = Animation(x=500, y=500, duration=1)
anim.start(self.stone)
Clock.schedule_once(lambda dt: self.stone_info(), 1)
self.add_widget( self.stone )
def stone_info(self):
print "pos:", self.stone.pos, "size:", self.stone.size
class GoStone(Widget):
def __init__(self, **kwargs):
super(GoStone, self).__init__(**kwargs)
with self.canvas:
Color(1,1,1,.5)
Rectangle(pos=self.pos, size=self.size)
class TTGoApp(App):
def build(self):
return GoGame()
if __name__ == '__main__':
TTGoApp().run()
Output:
[INFO ] Kivy v1.1.1
[INFO ] [Logger ] Record log in /home/duelafn/.kivy/logs/
kivy_12-03-28_33.txt
[INFO ] [Factory ] 102 symbols loaded
[INFO ] [Window ] using <pygame> as window provider
[INFO ] [GL ] OpenGL version <3.3.10666 Compatibility
Profile Context>
[INFO ] [GL ] OpenGL vendor <ATI Technologies Inc.>
[INFO ] [GL ] OpenGL renderer <ATI Mobility Radeon HD 4500
Series>
[INFO ] [GL ] Shading version <3.30>
[INFO ] [GL ] Texture max size <8192>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Shader ] fragment shader: <Fragment shader was
successfully compiled to run on hardware.>
[INFO ] [Shader ] fragment compiled successfully
[INFO ] [Shader ] vertex shader: <Vertex shader was
successfully compiled to run on hardware.>
[INFO ] [Shader ] vertex compiled successfully
[INFO ] [Shader ] program: <Vertex shader(s) linked, fragment
shader(s) linked.>
[INFO ] [Window ] virtual keyboard not allowed, single mode,
not docked
pos: [0, 0] size: [40, 40]
pos: [80.0, 80.0] size: [40, 40]
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Base ] Start application main loop
pos: [500.0, 500.0] size: [40, 40]
[INFO ] [Base ] Leaving application in progress...