Hi,
I'm fairly new to kivy, so I might just be doing things the wrong way, but I have what I tend to consider to be a bug even though it might not be the case.
Consider this kv file :
#:kivy 1.0
<MainMenuButton@Button>
mycustomscale: 0
#pos: (root.pos[0]), self.parent.height/2
pos: (root.pos[0]) + (self.mycustomscale * 10), self.parent.height/2
Button:
MainMenuButton:
mycustomscale: 30
text:'Top left'
size: root.width / 5, root.height/3
#center: root.center_x + root.width, root.center_y
Running this code produces a white screen with the main loop returning the following traceback :
File "kivy\weakproxy.pyx", line 22, in kivy.weakproxy.WeakProxy.__setattr__ (kivy\weakproxy.c:1235)
File "kivy\properties.pyx", line 408, in kivy.properties.Property.__set__ (kivy\properties.c:5114)
File "kivy\properties.pyx", line 1268, in kivy.properties.ReferenceListProperty.set (kivy\properties.c:20384)
File "kivy\properties.pyx", line 501, in kivy.properties.Property.dispatch (kivy\properties.c:6557)
File "kivy\_event.pyx", line 1224, in kivy._event.EventObservers.dispatch (kivy\_event.c:13497)
File "kivy\_event.pyx", line 1106, in kivy._event.EventObservers._dispatch (kivy\_event.c:12301)
File "C:\Program Files (x86)\Python2\lib\site-packages\kivy\lang.py", line 1569, in call_fn
setattr(element, key, e_value)
With the following error at startup :
File "main.py", line 9, in <module>
MainApp().run()
File "C:\Program Files (x86)\Python2\lib\site-packages\kivy\app.py", line 801, in run
self.load_kv(filename=self.kv_file)
File "C:\Program Files (x86)\Python2\lib\site-packages\kivy\app.py", line 598, in load_kv
root = Builder.load_file(rfilename)
File "C:\Program Files (x86)\Python2\lib\site-packages\kivy\lang.py", line 1842, in load_file
return self.load_string(data, **kwargs)
File "C:\Program Files (x86)\Python2\lib\site-packages\kivy\lang.py", line 1921, in load_string
self._apply_rule(widget, parser.root, parser.root)
File "C:\Program Files (x86)\Python2\lib\site-packages\kivy\lang.py", line 2130, in _apply_rule
e), cause=tb)
kivy.lang.BuilderException: Parser: File ".\main.kv", line 12:
...
10:
11: MainMenuButton:
>> 12: mycustomscale: 30
13: text:'Top left'
14: size: root.width / 5, root.height/3
...
RuntimeError: maximum recursion depth exceeded
So , the problem seems to be the fact that I make a new assignment to a custom variable when it has already been assigned and is used by the parent class. The problem doesn't occur if the variable is one of the default kivy variables, is used in the child class instead of the parent or is set in the child class but not used in the parent class.
I thought about sending an issue on github as it doesn't seem to have been reported yet, however I'd like to know wether this behavior is expected first.
Can someone tell me ?
I know that a simple workaround would be to use python classes instead of kv or to set the position in every child class instead of the parent, but that doesn't feel as 'clean' as what I'm trying to do and I'd really like to do it this way (if you know other ways I'd love to hear it though)
Sorry for the mistakes I have probably made, I'll try to improve my english in the future.
ps : I'm using kivy on windows