I am just learning kivy. I wrote a few lines and I tried to run. To many errors: Code:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class mainWindow(BoxLayout):
pass
class mainApp(App):
def build(self):
return mainWindow
app=mainApp()
app.run()
Errors:
[INFO ] [Logger ] Record log in C:\Users\Salvatore Pennisi\.kivy\logs\kivy_21-10-02_44.txt
[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\Salvatore Pennisi\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\Salvatore Pennisi\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)
Traceback (most recent call last):
File "c:\Users\Salvatore Pennisi\Desktop\Personal Home\Lavoro - progetti-studio\programmazione\Traduttore documenti\main.py", line 78, in <module>
app.run()
File "C:\Users\Salvatore Pennisi\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\app.py", line 949, in run
self._run_prepare()
File "C:\Users\Salvatore Pennisi\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\app.py", line 918, in _run_prepare
self.load_kv(filename=self.kv_file)
File "C:\Users\Salvatore Pennisi\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\app.py", line 691, in load_kv
root = Builder.load_file(rfilename)
File "C:\Users\Salvatore Pennisi\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 306, in load_file
return self.load_string(data, **kwargs)
File "C:\Users\Salvatore Pennisi\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 404, in load_string
widget = Factory.get(parser.root.name)(__no_builder=True)
File "C:\Users\Salvatore Pennisi\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\factory.py", line 144, in __getattr__
raise AttributeError(
AttributeError: First letter of class name <import kivy> is in lowercase
What am I doing wrong? I'd like to made a simple window and then add some features.
The build()
method must return an instance of a widget, but return mainWindow
is returning a class. Try changing that line to:
return mainWindow()
Also, your class names should start with a capital letter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.