PalimPalim
PalimPalim

Reputation: 3048

Kivy Background Color, widgets not visible

Why isn't the Label with text 'Palim' visible? What is a good way of setting the background color and than placing widgets on top?

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
Builder.load_string("""
<rootwid>:
    canvas.before:
        Color:
            rgba: [1,1,1,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()

Upvotes: 0

Views: 300

Answers (1)

el3ien
el3ien

Reputation: 5405

It is not visible because you place a white label on a white background.
Try make the background gray:

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()

Upvotes: 1

Related Questions