https://gist.github.com/spillz/cb68aca4f4595d13a9fc
If i change my_rect_size to size it works just fine, so I guess it has something to do with the property being initialized after the first canvas call. If so, is that a bug? Or is there some other way to do these sorts of canvas calculations (the actual use case is more complex than this trivial example and so just moving the calculations to the rectangle is not desirable and would result in a lot of repetition)
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import ListProperty
Builder.load_string('''
#:kivy 1.6
<MyLayout>:
my_rect_size: self.size[0]/2, self.size[1]/2
canvas:
Color:
rgba: [0,1,0,1]
Rectangle:
pos: self.pos
size: self.my_rect_size
''')
class MyLayout(FloatLayout):
my_rect_size=ListProperty([0,0])
def __init__(self,**kwargs):
super(MyLayout, self).__init__(**kwargs)
class MyApp(App):
def build(self):
return MyLayout()
if __name__ == '__main__':
MyApp().run()