Changing background color in kivy [duplicate]

拈花ヽ惹草 提交于 2019-12-12 04:34:47

问题


I would like to change the background (black color) to a different color in kivy. But the Color specification in kv file is not recognized.

main.py

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder

class MatrixCalcLayout(BoxLayout):
    def calculations(self):
        pass

class ConfusionMatrixCalcApp(App):
    pass

if __name__ == '__main__':
    ConfusionMatrixCalcApp().run()

ConfusionMatrixCalc.kv file

MatrixCalcLayout:

<MatrixCalcLayout>:
    canvas:
        Color:
            rgba: 0.5, 0.5, 0.5, 0.5
    orientation: 'vertical'
    BoxLayout:
        Label:
    BoxLayout:
        Button:
    BoxLayout:
        Button:
    BoxLayout:
        Button:

回答1:


After Color you need to draw something, in your case, a Rectangle

canvas:
    Color:
        rgba: 0.5, 0.5, 0.5, 0.5
    Rectangle: #woohoo!!!
        size: self.size
        pos: self.pos


来源:https://stackoverflow.com/questions/42610635/changing-background-color-in-kivy

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