首页 > 解决方案 > 访问给定小部件中的不同小部件属性

问题描述

需要知道如何从 kv 语言的不同属性中访问小部件属性。我有一个不同的应用程序,将提供一个更简单的版本。

不太确定如何使用小部件树 ID 引用或应用程序或根。没有任何帮助。

在我的 kv 文件中

标签: pythonkivy

解决方案


带身份证。

rootWidget:    
    Widget1:
        id: w1
        Widget2:
            id: w2
        Widget3:
            id: w3
    Widget4:
        id: w4

您现在可以在 kv 中访问这三个小部件:

root.orientation = "vertical"
w1.orientation = "vertical" "if this is a label for example" 
w2.text = "if this is a label for example"
w3.property = something
w4.property = something

推荐阅读