I have the following code:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class TestGUI(BoxLayout):
pass
class TestApp(App):
def build(self):
return TestGUI()
if __name__ == '__main__':
TestApp().run()
and the corresponding .kv
file:
#:kivy 1.9.1
<TestGUI>:
temp_size: (0.5 * x for x in self.size)
canvas.before:
Color:
rgba: (1, 0, 0, 1)
Rectangle:
size: self.temp_size
The code does not run, throwing:
TypeError: 'NoneType' object is not iterable
due to the last line of code in the kv
file. It seems that self.size
is not initialized when temp_size
is declared, but this raises a few questions.
Why am I allowed to iterate through
self.size
when declaringtemp_size
if it is aNoneType
object?Also, why does the code work perfectly fine when I replaces the last line with
size: (0.5 * x for x in self.size)
instead of using a variable?Also, how can I circumvent this issue and assign variables based on the value of
self.size
?