0
votes

I am trying to pass an id to a button using python main file. This code used to work on previous versions of kivy. I just installed kivy 2.0 for this but it is returning the following error:

super(Widget, self).init(**kwargs)

File "kivy_event.pyx", line 245, in kivy._event.EventDispatcher.init

TypeError: object.init() takes exactly one argument (the instance to initialize)

It works when I remove the id from the button

            btn = Button(text='Delete (X)', id="school", bold=True, color=(1, 1, 1, 1),
                         background_color=(1, 0.8, 0.8, 1), size_hint=(None, None), font_size=15, size= 
                         (100, 25),
                         pos_hint=({'center_x': .5}), on_release=lambda btn: Education().delete(btn.id))```
1

1 Answers

0
votes

The id= is not a legal argument to the Button constructor, so it gets passed along to super classes until it reaches the base class (object), which does not accept any arguments other than self. So it throws an exception.

If you are thinking of the id from the kivy language, note that the id: is special in the kivy language and is used to create a dictionary of widgets in the root widget of a rule. And the specified id is used in that dictionary, but does not become a property of the widget where it appears.