0

I was following a Kivy tutorial by Tech With Tim and ran into an error (TypeError: add_widget() missing 1 required positional argument: 'widget') which I have no idea how to resolve, here's the source code:

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class MyGrid(GridLayout):
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 1

        self.inside = GridLayout
        self.inside.cols = 2

        self.inside.add_widget(Label(text='Name: '))        *<---- ERROR HERE*
        self.name = TextInput(multiline=False)
        self.inside.add_widget(self.name)

        self.inside.add_widget(Label(text='Last name: '))
        self.lastName = TextInput(multiline=False)
        self.inside.add_widget(self.lastName)

        self.inside.add_widget(Label(text='Email: '))
        self.email = TextInput(multiline=False)
        self.inside.add_widget(self.email)

        self.add_widget(self.inside)

        self.submit = Button(text='Click Me!', font_size=20)
        self.add_widget(self.submit)


class MyApp(App):
    def build(self):
        return MyGrid()


if __name__ == '__main__':
    MyApp().run()

1 Answer 1

1

Change self.inside = GridLayout to self.inside = GridLayout()

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, didn't notice that
@MGPFE, please when someone answers your question correctly, mark his/her answer as the "right answer".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.