Reputation: 83
I try to run the code of my Kivy app, but things go wrong when I'm creating a new class. This is the code for it:
class MyGrid(GridLayout):
def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text="First Name: "))
self.name = TextInput(multiline=False)
self.add_widget(self.name)
The code doesn't work because of an error in the second line with def __init__(self, **kwargs)
. The code returns:
SyntaxError: invalid syntax.
I don't know what's wrong with the syntax. What could be going wrong?
Upvotes: 1
Views: 1317
Reputation: 11
For anyone coming from Tech with Tim's Video, being confused as to why this happens, there is a Typo beneath Class MyGrid(GridLayout):
There needs to be a space between def
and __init__
.
Upvotes: 1