本文介绍了在猕猴桃中更改背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将背景色(黑色)更改为猕猴桃色.但是无法识别kv文件中的颜色规范.

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文件

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:

推荐答案

颜色之后,您需要绘制一个对象,例如矩形矩形

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

这篇关于在猕猴桃中更改背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 14:47