Reputation: 6185
I have a dynamic classes like this:
<BLMother@BoxLayout>:
orientation:"horizontal"
padding: 10, 0
spacing: 10
For some of my CustomBoxLayout, I would like to add a canvas:before. I could create a new dynamic classes which combine the values of both like this:
<BLChildren@BoxLayout>:
orientation:"horizontal"
padding: 10, 0
spacing: 10
canvas.before:
Color:
rgba: 1, 1, 1, 0.8
Rectangle:
size: self.size
pos: self.x + self.width*0.025, self.y
Is there a way BLChildren
can inherit all the value from BLMother
?
I use Kivy (1.10.1.dev0)
Upvotes: 0
Views: 767
Reputation: 2645
i don't know why you put pos = self.x + self.width*0.025, self.y but here you go:
-kv:
<BLMother@BoxLayout>:
orientation:"horizontal"
padding: 10, 0
spacing: 10
<BLChildren@BLMother>:
canvas.before:
Color:
rgba: 1, 1, 1, 0.8
Rectangle:
size: self.size
pos: self.x , self.y
BLChildren:
-py:
from kivy.app import App
class TestApp(App):
pass
if __name__ == "__main__":
TestApp().run()
Upvotes: 1
Reputation: 16011
Yes, the BLChildren can inherit all the value from BLMother. Please refer to the example below for details.
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
class RootWidget(FloatLayout):
pass
class TestApp(App):
title = "With Inheritance of BLMother"
def build(self):
return RootWidget()
if __name__ == "__main__":
TestApp().run()
#:kivy 1.10.0
<BLMother@BoxLayout>:
orientation:"horizontal"
padding: 10, 0
spacing: 10
<BLChildren@BoxLayout>:
canvas.before:
Color:
rgba: 1, 1, 1, 0.8
Rectangle:
size: self.size
pos: self.x + self.width*0.025, self.y
BLMother:
<RootWidget>:
BLChildren:
Upvotes: 1