问题
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