Why is MyApp Instance not executing on python run

Question:

enter image description hereI’m writing a simple code for executing an application in python kivy module I use Pycharm, the syntax is okay but its returning an error saying:

 File "C:UsersUSERPycharmProjectspythonProject7main.py", line 12, in <module>
     TestNas().run()
 TypeError: TestNas() missing 1 required positional argument: 'app'

I was expecting it to start the simple Kivy Gui but it did not.

import kivy
from kivy.app import App
from kivy.uix.label import Label


def TestNas(app):
    def build(self):
        return Label(Text="Test this app")


if __name__ == '__main__':
    TestNas().run()
Asked By: user20326975

||

Answers:

First of all TestNas() should be a class and I’m guessing it needs to be a subclass of App() that you imported. So change TestNas() to a class and capitalize App().

I think this is the code you need:

import kivy
from kivy.app import App
from kivy.uix.label import Label


class TestNas(App):
    def build(self):
        return Label(Text="Test this app")


if __name__ == '__main__':
    TestNas().run()
Answered By: user99999
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.