<legend id='dYeBW'><style id='dYeBW'><dir id='dYeBW'><q id='dYeBW'></q></dir></style></legend>
  • <tfoot id='dYeBW'></tfoot>
    • <bdo id='dYeBW'></bdo><ul id='dYeBW'></ul>

    <small id='dYeBW'></small><noframes id='dYeBW'>

      1. <i id='dYeBW'><tr id='dYeBW'><dt id='dYeBW'><q id='dYeBW'><span id='dYeBW'><b id='dYeBW'><form id='dYeBW'><ins id='dYeBW'></ins><ul id='dYeBW'></ul><sub id='dYeBW'></sub></form><legend id='dYeBW'></legend><bdo id='dYeBW'><pre id='dYeBW'><center id='dYeBW'></center></pre></bdo></b><th id='dYeBW'></th></span></q></dt></tr></i><div id='dYeBW'><tfoot id='dYeBW'></tfoot><dl id='dYeBW'><fieldset id='dYeBW'></fieldset></dl></div>

        如何将一个属性绑定到 Kivy 中的另一个属性?

        时间:2023-10-09
        <i id='kUxd0'><tr id='kUxd0'><dt id='kUxd0'><q id='kUxd0'><span id='kUxd0'><b id='kUxd0'><form id='kUxd0'><ins id='kUxd0'></ins><ul id='kUxd0'></ul><sub id='kUxd0'></sub></form><legend id='kUxd0'></legend><bdo id='kUxd0'><pre id='kUxd0'><center id='kUxd0'></center></pre></bdo></b><th id='kUxd0'></th></span></q></dt></tr></i><div id='kUxd0'><tfoot id='kUxd0'></tfoot><dl id='kUxd0'><fieldset id='kUxd0'></fieldset></dl></div>

        • <bdo id='kUxd0'></bdo><ul id='kUxd0'></ul>
        • <legend id='kUxd0'><style id='kUxd0'><dir id='kUxd0'><q id='kUxd0'></q></dir></style></legend>

                  <small id='kUxd0'></small><noframes id='kUxd0'>

                    <tbody id='kUxd0'></tbody>
                  <tfoot id='kUxd0'></tfoot>

                  本文介绍了如何将一个属性绑定到 Kivy 中的另一个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想将小部件的属性绑定到子小部件的属性.因此,当根小部件属性发生更改时,更改也会传播到子属性.

                  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.

                  我是这样尝试的:

                  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)
                  

                  但在 Kivy,我可以做到:

                  But in Kivy, I could do:

                  <RootWidget>
                      <ChildWidget>
                          _MyProperty: self.parent._MyProperty
                  

                  问题是我想用 Python,而不是 Kivy.

                  The problem is I want to do it in Python, not in Kivy.

                  推荐答案

                  要将一个属性绑定到另一个属性,您应该使用 setter 事件:

                  To bind one property to another you should use the setter event:

                  self.bind(_MyProperty=self._Child.setter('_MyProperty'))
                  

                  这篇关于如何将一个属性绑定到 Kivy 中的另一个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Kivy 中创建全局变量 下一篇:Kivy:App.root 中的无效实例

                  相关文章

                  最新文章

                • <tfoot id='GC568'></tfoot>
                  <i id='GC568'><tr id='GC568'><dt id='GC568'><q id='GC568'><span id='GC568'><b id='GC568'><form id='GC568'><ins id='GC568'></ins><ul id='GC568'></ul><sub id='GC568'></sub></form><legend id='GC568'></legend><bdo id='GC568'><pre id='GC568'><center id='GC568'></center></pre></bdo></b><th id='GC568'></th></span></q></dt></tr></i><div id='GC568'><tfoot id='GC568'></tfoot><dl id='GC568'><fieldset id='GC568'></fieldset></dl></div>

                  1. <legend id='GC568'><style id='GC568'><dir id='GC568'><q id='GC568'></q></dir></style></legend>
                      <bdo id='GC568'></bdo><ul id='GC568'></ul>

                      <small id='GC568'></small><noframes id='GC568'>