最近我下载了Kivy模块,我认为我已经正确安装了它,但是当我尝试以下代码时:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text="Hello World")
TestApp.run()
,并出现以下错误:
[INFO ] [Logger ] Record log in C:\Users\User\.kivy\logs\kivy_18-06-
24_6.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46)
[MSC v.1900 32 bit (Intel)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil, img_gif
(img_sdl2, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pil(['text_sdl2'] ignored)
Traceback (most recent call last):
File "C:\Users\User\Desktop\experiments - 3 (1).py", line 34, in <module>
TestApp.run()
TypeError: run() missing 1 required positional argument: 'self'
答案 0 :(得分:0)
您应该创建此类的实例并在其上调用方法:
app = TestApp()
app.run()