简体   繁体   中英

Kivy (framework):'me' object has no attribute 'built'

when i tried to run my code python gave me this error:

\kivy\app.py", line 916, in _run_prepare if not self.built: AttributeError: 'me' object has no attribute 'built'

 import kivy from kivy.app import App from kivy.uix.button import Button from kivy.uix.gridlayout import GridLayout from kivy.uix.label import Label from kivy.uix.textinput import TextInput class me(App): def __init__(self,b,g,l,t): self.b=Button(text='start') self.g=GridLayout(cols=4) self.l=Label(text='label') self.t=TextInput() self.g.add_widget(self.b) self.g.add_widget(self.t) self.g.add_widget(self.l) m=me('b','g','l','t') m.run()

what is the problem in this code?

When you over-ride a method of a super class (like __init__() in your case), you must call the over-ridden method of the super class. Just add the line:

super(me, self).__init__()

to your __init__() method.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM