Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you wrap lines in a kivy file?

I have a couple of lines in my kv. file that are really long (80+ chars), and I was wondering if there was a way to wrap/continue them on the next line.

For example, how do I go from this

Line:
    points: self.pos[0] + 5, self.pos[1] + 2, self.pos[0] + self.width - 5, self.pos[1] + 2

to

Line:
    points: self.pos[0] + 5, self.pos[1] + 2, 
            self.pos[0] + self.width - 5, self.pos[1] + 2

or something similar.


1 Answers

Acording to https://kivy.org/docs/api-kivy.lang.html#valid-expressons, you can use line continuation character (\):

Line:
    points:
        self.pos[0] + 5, self.pos[1] + 2,\ 
        self.pos[0] + self.width - 5, self.pos[1] + 2

New line shouldn’t add an indentation level. Note that the following syntax is invalid:

Line:
    points: self.pos[0] + 5, self.pos[1] + 2,\ 
            self.pos[0] + self.width - 5, self.pos[1] + 2

Another valid example:

canvas:
    Rectangle:
        pos:
            self.center_x-5,\
            0
        size:
            10,\
            self.height 
like image 155
FJSevilla Avatar answered Oct 26 '25 18:10

FJSevilla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!