The kivy application window does not start, I don’t know what’s the matter. This is the simplest Hello World app, but the window just not appears. Here is the code in main.py:
from kivy.uix.button import Button from kivy.uix.boxlayout import BoxLayout class Container(BoxLayout): pass class FirstApp(App): def build(self): return Container() if "__name__" == "__main__": FirstApp.run()
also in first.kv:
Button: text: "Hello"
Here are the logs:
[INFO ] [Kivy ] v2.0.0 [INFO ] [Kivy ] Installed at "/usr/local/lib/python3.9/site-packages/kivy/__init__.py" [INFO ] [Python ] v3.9.6 (default, Jun 29 2021, 06:20:32) [Clang 12.0.0 (clang-1220.127.116.11)] [INFO ] [Python ] Interpreter at "/firstname.lastname@example.org/bin/python3.9" [INFO ] [Factory ] 186 symbols loaded [INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2
It doesn’t look like there is any error here. I use mac os, Catalina, I also tried parallels desktop on a virtual machine (both on Ubuntu and Windows) Sorry for my English, I’m not from English speaking country. Help me, please!
this is how should be
from kivy.uix.button import Button from kivy.uix.boxlayout import BoxLayout class Container(BoxLayout): pass class FirstApp(App): def build(self): return Container() # the main reason that your code is not running because you make __name__ as # string so this condition will never be true so the app will not load if __name__ == "__main__": FirstApp().run()
and for kv file
<Container>:# you miss this line which the root widget Button: text: "Hello"