Can you wrap lines in a kivy file?

橙三吉。 提交于 2020-06-28 08:08:06

问题


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:


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 


来源:https://stackoverflow.com/questions/44958627/can-you-wrap-lines-in-a-kivy-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!