from kivy.app import App
class MyApp(App):
pass
if __name__ == "__name__":
Myapp().run()
加载停止:
[INFO ] [Logger ] Record log in C:\Users\admin\.kivy\logs\kivy_18-04-13_14.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_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
哪里有问题?
答案 0 :(得分:1)
由于您未在build()
方法中返回root
,因此应用程序无法启动,因此kivy不会加载更多组件,因此应用程序将关闭。
<强>解决方案:强>
返回一个小部件。
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='hello world')
if __name__ == '__main__':
TestApp().run()