rand0mb0t
rand0mb0t

Reputation: 144

How can I specify color to rectangle in kivy file (one with .kv extension)

I tried PongGame tutorial which was just fine then I started making a new app on my own and want to have color on the rectangle rather than just a white recctangle

i've tried

#: kivy 1.9.2

<FireGame>:
    canvas:
        color: [1, 1, 0, 1]

        Rectangle:
            pos: root.width - 30, 0
            size: 30,self.height/2 - self.height/6  

but it resulted in error

[INFO   ] [Logger      ] Record log in 
C:\Users\RanD0mB0t\.kivy\logs\kivy_17-04-19_63.txt
[INFO   ] [Kivy        ] v1.9.2.dev0, git-fd01c09, 20170418
[INFO   ] [Python      ] v3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) 
[MSC v.1900 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif 
(img_pil, img_ffpyplayer ignored)
Traceback (most recent call last):
File "main.py", line 6, in <module>
 Builder.load_file('./fire.kv')
File "C:\Python36\lib\site-packages\kivy\lang\builder.py", line 301, in 
load_file
 return self.load_string(data, **kwargs)
File "C:\Python36\lib\site-packages\kivy\lang\builder.py", line 350, in 
load_string
 parser = Parser(content=string, filename=fn)
File "C:\Python36\lib\site-packages\kivy\lang\parser.py", line 392, in 
__init__
 self.parse(content)
File "C:\Python36\lib\site-packages\kivy\lang\parser.py", line 496, in parse
  objects, remaining_lines = self.parse_level(0, lines)
File "C:\Python36\lib\site-packages\kivy\lang\parser.py", line 643, in 
parse_level
 level + 2, lines[i:], spaces)
File "C:\Python36\lib\site-packages\kivy\lang\parser.py", line 570, in 
parse_level
 'Invalid data after declaration')
 kivy.lang.parser.ParserException: Parser: File "E:\New 
folder\kivy\Firegame\fire.kv", line 9:
 ...
      7:                       size: 30,self.height/2 - self.height/6
      8:
>>    9:               color: [1, 1, 0, 1]
 ...
 Invalid data after declaration

Upvotes: 2

Views: 2641

Answers (1)

rand0mb0t
rand0mb0t

Reputation: 144

Got it working now it seems that i specified rgba values in a list but they are to be lying around like also the color attribute starts with capital C

Color:
    rgba: 1,1,1,1

Upvotes: 1

Related Questions