How do you render a white background in kivy using a kv file implementation?

Viewed 67

I've been trying to create a simple application for android, and I've started working on the GUI first.
However, after I finished the tutorial, and tried implementing my own GUI, it stopped working. The official documentation does not focus on .kv files, answers found in other questions here on SO all have different answers, and I am just lost.
All I need is the root widget, which has a white rectangle the size of the screen, to be rendered. Below is the minimum reproducable code.
I've tried:

  • changing canvas to Canvas, and canvas.before as written in another answer from SO.
  • Building the app using Builder.load_file()
  • Changing the build() override to pass

None worked.
Any help is appreciated.
My KV File (GutTrust.kv)

#:kivy 1.0.1

gutScreen:
    Canvas:
        Color:
            rgba: 1, 1, 1, 1
        Rectangle:
            pos: self.pos
            size: self.size
    #Many more elements but they are unnessesary for the demonstration.

My Python File (main.py)

from kivy.app import App
from kivy.uix.widget import Widget


class gutScreen(Widget):
    """Background"""
    pass

class GutTrustApp(App):
    def build(self):
        return gutScreen()

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

1 Answers

rename "gutScreen" to "GutScreen". replace "GutScreen:" with ":" in kv. replace "Canvas" with "canvas". That'd work. – Nattōsai Mitō

And rename GutTrust.kv to guttrust.kv – John Anderson

Those two comments solved the problem. Thank you!

Related