[Python] Kivy showing a black screen when trying to use kv file?

Discussão em 'Python' iniciado por Stack, Dezembro 18, 2024.

  1. Stack

    Stack Membro Participativo

    So I want to do the styling of my Kivy app in a external .kv file, but when I run the main code, nothing appears to the black Kivy window.

    Here's my main file called main.py

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

    class MyGrid(Widget):
    pass

    class MyApp(App):
    def build(self):
    return MyGrid()

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


    And here's the .kv file located in the same directory and called my.kv

    #:kivy 2.0.0
    <MyGrid>:
    Label:
    text: "example example"


    So I'm not getting any error, just nothing appearing in the Kivy GUI when I run the main code.

    Why is this and how to fix it?

    Continue reading...

Compartilhe esta Página