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

Time:02-05

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?

CodePudding user response:

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.

  •  Tags:  
  • Related