python - Kivy: Invalid instance in App.root -
python - Kivy: Invalid instance in App.root -
i new python kivy, first little project, , don't know did wrong, next log pydev(eclipse):
[info ] kivy v1.8.0 [info ] [logger ] record log in c:\users\sudheer\.kivy\logs\kivy_14-06-21_10.txt [info ] [factory ] 157 symbols loaded [debug ] [cache ] register <kv.lang> limit=none, timeout=nones [debug ] [cache ] register <kv.image> limit=none, timeout=60s [debug ] [cache ] register <kv.atlas> limit=none, timeout=nones [info ] [image ] providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored) [debug ] [cache ] register <kv.texture> limit=1000, timeout=60s [debug ] [cache ] register <kv.shader> limit=1000, timeout=3600s [info ] [text ] provider: pygame [debug ] [cache ] register <kv.loader> limit=500, timeout=60s [info ] [loader ] using thread pool of 2 workers [debug ] [cache ] register <textinput.label> limit=none, timeout=60.0s [debug ] [cache ] register <textinput.width> limit=none, timeout=60.0s [debug ] [app ] loading kv <d:\os files\workspace\kal\src\myclass.kv> [debug ] [app ] kv <d:\os files\workspace\kal\src\myclass.kv> not found [critical ] app.root must _instance_ of widget traceback (most recent phone call last): file "d:\os files\workspace\kal\__main__.py", line 9, in <module> myclass().run() file "c:\kivy180\kivy\kivy\app.py", line 772, in run raise exception('invalid instance in app.root') exception: invalid instance in app.root
code file construction follows:
codes follows: file:main.py
from src.appstart import myclass if __name__ == '__main__': myclass().run()
file:appstart.py:
from kivy.app import app src.logins.loginform import loginform kivy.uix.button import button class myclass(app): ''' classdocs ''' def build(self): c=loginform #c=button(text="checked") homecoming c
file:loginform.py:
from kivy.uix.gridlayout import gridlayout kivy.graphics import color kivy.uix.label import label kivy.uix.textinput import textinput class loginform(gridlayout): ''' classdocs ''' def __init__(self, **kwargs): #kwargs['cols'] = 1 #layout=gridlayout(cols=2, rows=3, background_color=color(1,1,1)) self.cols=2 self.rows=3 self.background_color=color(1,1,1) idlbl =label(text="user id: ") pwlbl =label(text="password: ") idtxtbox = textinput(text="",multiline=false) pwtxtbox = textinput(text="",multiline=false, password=true) self.add_widget(idlbl) self.add_widget(pwlbl) self.add_widget(idtxtbox) self.add_widget(pwtxtbox) #return layout super(loginform, self).__init__(**kwargs)
could please allow me know why app.root invalid instance,
the homecoming value of app.build()
assigned app.root
. in build()
homecoming class (loginform
) instead of instance of class. changing line in build()
c = loginform()
should prepare it.
python python-3.x pydev kivy
Comments
Post a Comment