Maza
Maza

Reputation: 1

Kivy error while running : TypeError: run() missing 1 required positional argument: 'self'

I was just watching a tutorial on kivy and for some reason my code won't work as the person teaching

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

class myapp(App) :

    def build(self):
        return Label(text = "Hello world")

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

thats the code and

[INFO   ] [Logger      ] Record log in C:\Users\Maza\.kivy\logs\kivy_21-10-13_21.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "C:\Users\Maza\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\Maza\AppData\Local\Programs\Python\Python39\python.exe"
[INFO   ] [Factory     ] 186 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
 Traceback (most recent call last):
   File "c:\Users\xxx\Documents\Projects\Python playground\Kivy\test1.py", line 12, in <module>
     myapp.run()
 TypeError: run() missing 1 required positional argument: 'self'

that's what it returned. I still dont know how to fix it

Upvotes: 0

Views: 903

Answers (1)

John Anderson
John Anderson

Reputation: 38937

You need to change:

myapp.run()

to:

myapp().run()

That is, you must create an instance of myapp (the myapp() with parens), then call the run() method of that instance.

Upvotes: 2

Related Questions