from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.properties import StringProperty
from kivy.properties import ListProperty
from kivy.graphics.vertex_instructions import Rectangle
from kivy.graphics.context_instructions import Color
Builder.load_string('''
<bbx>:
orientation: 'vertical'
my2App:
color: 1,0,0,1
<my2App>:
text: root.text
Label:
text: root.text
font_size: 16
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
canvas:
Color:
rgba: root.color
Rectangle:
pos: self.pos
size: self.size
''')
class my2App(ScrollView):
text = StringProperty('default string'*200)
color = ListProperty([1,0,0,0.25])
class bbx(BoxLayout):
pass
runTouchApp(bbx())
This is my practice kivy code. my2App is a user defined widget mostly copied from this tutorial (https://www.youtube.com/watch?v=WdcUg_rX2fM). The only addition is the color property defined by ListProperty. Somehow this user defined color property didn't work out. I tried to run my2App along and it didn't work either.
> Traceback (most recent call last): File "test_anotherviky.py", line
> 38, in <module>
> ''') File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1796, in load_string
> parser = Parser(content=string, filename=fn) File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1185, in
> __init__
> self.parse(content) File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1291, in parse
> rule.precompile() File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1049, in
> precompile
> x.precompile() File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 976, in
> precompile
> self.co_value = compile(value, self.ctx.filename or '<string>', mode) File "<string>", line 5
> color: 1,0,0,1
> ^ SyntaxError: invalid syntax