TypeError: __init __ () got unexpected keyword argument '__no_builder' Kivy
I am trying to add def __init__(self)
to my code and when I run the kivy program I get this:
Traceback (most recent call last):
File "/Users/acrobat/Desktop/dive/test.py", line 78, in <module>
''')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kivy/lang.py", line 1921, in load_string
self._apply_rule(widget, parser.root, parser.root)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kivy/lang.py", line 2085, in _apply_rule
self._apply_rule(child, crule, rootrule)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kivy/lang.py", line 2082, in _apply_rule
child = cls(__no_builder=False)
TypeError: __init__() got an unexpected keyword argument '__no_builder'
Here is the code:
def __init__(self)
is in a class PlayerImage
, which is the widgets I am trying to move around the screen
class PlayerImage(Image):
angle = NumericProperty(0)
def __init__(self):
super().__init__()
def on_touch_down(self, touch):
# self.currentstate = self.states["person.zip/"]
Animation.cancel_all(self)
angle = degrees(atan2(touch.y - self.center_y,
touch.x - self.center_x))
Animation(center=touch.pos, angle=angle).start(self)
# self.currentstate = self.states["personred/rest.png/"]
I am not using kv lang file, so here is my assembly code:
root = Builder.load_string('''
Widget:
Widget:
PlayerImage:
source: './rpgArt/person.zip'
allow_stretch: True
keep_ratio: True
PlayerImage2:
source: './rpgArt/personred.zip'
allow_stretch: True
keep_ratio: True
''')
EDIT : Added kivy tag
source to share
Replace:
def __init__(self):
super().__init__()
FROM
def __init__(self, **kwargs):
super(PlayerImage, self).__init__(**kwargs)
You are subclassing an object without passing in the keyword arguments that Kivy requires.
I also don't think __init__()
Kivy is required, I think it can automatically look for it from you from the parent, but I'm not sure.
Edited: As Kevin said in the comments, since you are using Python 3, you can use null arguments super()
, which would be just as valid.
source to share