Reputation: 85
I want to bind a property of a widget to a property of a child widget. Thus when the root widget property is changed, the change is propagated to the child property as well.
I tried it this way:
self._Child._MyProperty = self._MyProperty
This works... sometimes. But sometimes it does not work. I cannot find out when it works or why and under which conditions it does not work.
In all cases I have a binding to a method in the root widget as well:
self.bind(_MyPropert = self._MyPropertyChange)
This method is called in all cases, but sometimes the change is not propagated to the child property.
This does not work even if it feels very natural:
self.bind(_MyProperty = self._Child._MyProperty)
But in Kivy, I could do:
<RootWidget>
<ChildWidget>
_MyProperty: self.parent._MyProperty
The problem is I want to do it in Python, not in Kivy.
Upvotes: 3
Views: 3037
Reputation: 39516
To bind one property to another you should use the setter event:
self.bind(_MyProperty=self._Child.setter('_MyProperty'))
Upvotes: 4