【问题标题】:How can I do a line break (line continuation) in a .KV file?如何在 .KV 文件中进行换行(续行)?
【发布时间】:2020-06-19 00:12:52
【问题描述】:

简单的问题,必须有一个简单的答案。

我有一长行代码可以确定 Kivy 中微调器的背景颜色。我只是想换行并在下面继续。我尝试将其括在括号中并使用反斜杠,但它仍然无法识别延续。

Spinner
    background_color: (root.nws if self.text == 'News' else root.brk if self.text == "Breaking" else root.spt if self.text == "Sports" else root.wth if self.text == "Weather" else root.ctc)

我尝试的任何中断都会返回错误“无效的属性名称”

【问题讨论】:

标签: python-3.x kivy


【解决方案1】:

解决方案:

background_color:
    root.nws if self.text == 'News' else root.brk if self.text == "Breaking" else root.spt if \
    self.text == "Sports" else root.wth if self.text == "Weather" else root.ctc

我的错误在于缩进,并没有在“background_color:”之后立即中断

谢谢你,罗纳德

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-26
    • 2010-09-08
    • 1970-01-01
    • 2021-02-03
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多