Search code examples
pythonvisual-studio-codekivy

VScode doesn't use the kivy file


I'm new to programming and trying to use Kivy to create a simple game. I am following a tutorial, and I'm using VSCode, but I can't understand why the code I write in the .kvfile doesn't is used by the main.pyfile.

I have two files in the directory.

  1. main.py
from kivy.app import App
from kivy.uix.widget import Widget



class MainWidget(Widget):
    pass

class TheLabApp(App):
    pass

TheLabApp().run()
  1. thelab.kv
MainWidget:


<MainWidget>:
    Button:
        text: 'Hello'
        size: 400, 200

I have installed a Kivy extension, and of course the Kivy module. But when I run the code the only thing that appears is a black screen, without the button. What is happening?


Solution

  • I found the solution. It is required to save the .kv file before running the code, it is just such a sily thing, but if it isn't saved it is read like if it was empty, or never changed.