Python Forum
[Kivy] 'Design' had no attribute 'add' Error in Python and Kivy - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Kivy] 'Design' had no attribute 'add' Error in Python and Kivy (/thread-18493.html)



'Design' had no attribute 'add' Error in Python and Kivy - yahucoder - May-20-2019

Dear All,
Good day, please am new to python development. When I try running this program the error message am getting is
//'ConnectPage' had no attribute 'add'

My code can be found below

import kivy
import os
os.environ ['KIVY_GL_BACKEND'] = 'angle_sdl2'

from kivy import Config
Config.set('graphics', 'multisamples', '0')

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
kivy.require("1.10.1")

class Design(GridLayout):
def init(self, kwargs):
super().init(kwargs)
self.cols = 2
self.add.widget(Label(text="Username"))
self.Username = TextInput(multiline=False)
self.add_widget(self.Username)

    self.add.widget(Label(text="Password"))
    self.Password = TextInput(multiline=False)
    self.add_widget(self.Password)

class ADU360(App):
def build(self):
return Design()

if name == "main":
ADU360().run()
This is the CMD Error
Traceback (most recent call last):
File "Login.py", line 30, in <module>
ADU360().run()
File "C:\Users\XXX\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\app.py", line 800, in run
root = self.build()
File "Login.py", line 27, in build
return Design()
File "Login.py", line 16, in __init__
self.add.widget(Label(text="Username"))
AttributeError: 'Design' object has no attribute 'add'

I really appreciate you guys help. Thank you in advance.


RE: 'Design' had no attribute 'add' Error in Python and Kivy - Yoriz - May-20-2019

self.add.widget should be self.add_widget


RE: 'Design' had no attribute 'add' Error in Python and Kivy - yahucoder - May-20-2019

Wao..... @Yoriz,
Thank you very much, you just save my head now.