How to access some widget attribute from another widget in Kivy?

一笑奈何 提交于 2019-12-02 08:51:44
  1. The object property l probably gets populated after the first event loop iteration, while you are trying to access it within the first. You could delay it till the second iteration to make it work.

  2. The most powerful approach is to bind those properties from inside python code, but there are some kv lang tricks to make it simpler. This is my favorite method:

BoxLayout

    Label
        id: label
        text: 'hello world'

    SubWidget
        label_text: label.text

<SubWidget@BoxLayout>
    label_text: 'none'

    Label
        text: root.label_text
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!