python - 访问给定小部件中的不同小部件属性
问题描述
需要知道如何从 kv 语言的不同属性中访问小部件属性。我有一个不同的应用程序,将提供一个更简单的版本。
不太确定如何使用小部件树 ID 引用或应用程序或根。没有任何帮助。
在我的 kv 文件中
- 作为根的小部件 1 有两个小部件 widget2、widget3。
- 小部件 2 有一个属性 var1
- 小部件 3 有一个小部件,其属性 var2 应随 var1 值的变化而变化
解决方案
带身份证。
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
推荐阅读
- javascript - TypeScript:空数组用值初始化,这些值不能改变
- python - 错误:“工作簿”对象没有属性“添加工作表”-> Python
- android - NDK 版本的 Gradle 构建错误 - ndk.dir 版本与 android.ndkVersion 不一致
- php - Windows 2016 服务器上的 PHP 代码 - JSON 似乎没有运行 (IIS)
- python - Pydrake:关于离散时间模拟中的渗透
- javascript - 如何在不中断其正常工作的情况下触发 ChartJS 图例 onClick
- laravel - 如何在mysql中显示产品表中的随机产品
- azureservicebus - ServiceBusProcessorClient 是否可以接收延迟消息?
- c# - 在 C# 中从流中创建缩略图
- javascript - Highcharts 上下文按钮放置在图例顶部的图例旁边