from kivy.app import App
from kivy.uix.widget import Widget
class kvtest(Widget):
pass
class myWidget(Widget):
pass
class kvtestApp(App):
def build(self):
return kvtest()
if __name__ == '__main__':
kvtestApp().run()
#:kivy 1.7.2
<myWidget>:
size_hint: None, None
canvas.after:
Color:
rgba: 1, 0, 0, .5
Rectangle:
size: self.size
pos: self.pos
<kvtest>:
AnchorLayout:
size_hint: None, None
size: self.parent.size
canvas.after:
Color:
rgba: 0, 1, 0, .1
Rectangle:
size: self.size
pos: self.pos
myWidget:
size: min(root.width , root.height) / 12, min(root.width, root.height) / 12
Traceback (most recent call last):
File "main.py", line 15, in <module>
kvtestApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 576, in run
self.load_kv(filename=self.options.get('kv_file'))
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 399, in load_kv
root = Builder.load_file(filename)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1323, in load_file
return self.load_string(data, **kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1360, in load_string
parser = Parser(content=string, filename=fn)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 930, in __init__
self.parse(content)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1007, in parse
rule.precompile()
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 802, in precompile
x.precompile()
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 798, in precompile
x.precompile()
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 733, in precompile
self.co_value = compile(value, self.ctx.filename or '<string>', mode)
File "./kvtest.kv", line 1
size: min(root.width , root.height) / 12, min(root.width, root.height) / 12
^
SyntaxError: invalid syntax
I forgot to add that changing myWidget to Widget in the .kv file makes the example work fine. The syntax error is not caused by the syntax of the "size" assignment - whatever I put there I receive the same error on the first line in the myWidget instance. It's like the builder does not understand myWidget class somehow, but I believe that it should be correct - Pong tutorial has similar declarations...
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.