Kivy背景颜色,小部件不可见

时间:2017-04-11 09:45:58

标签: python kivy

为什么标签上没有文字' Palim'可见?设置背景颜色的好方法是什么,而不是将小部件放在最上面?

 City     Name
    2  Portland  Mallory
    5  Portland  Mallory

1 个答案:

答案 0 :(得分:1)

由于您在白色背景上放置了白色标签,因此无法看到 尝试将背景设为灰色:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
Builder.load_string("""
<rootwid>:
    canvas.before:
        Color:
            rgba: [0.5,0.5,0.5,1]
        Rectangle:
            pos: self.pos
            size: self.size
    Label:
        text:'Palim'""")

class rootwid(BoxLayout):
    pass

class Testapp(App):
    def build(self):
        return rootwid()

Testapp().run()