python - 如何在kivy中使用“if,else if,else”条件
问题描述
如何在 kivy 中创建条件文本标签,例如 if x=1 text='Hi' if x=2 text='Hello' if x=1 text='helloword'
Label:
text:'hi' if root.x=='1''hello' elseif root.x=='1' else 'helloworls'
像这样的东西
解决方案
之后的部分text:
是 Python 语法(不是特定于 kivy 的):
text:'hi' if root.x=='1' else 'hello' if root.x=='2' else 'helloworls'
推荐阅读
- javascript - 如何在xslt2.0中使用javascript函数?
- r - API调用问题
- sharepoint-2016 - 尝试在 SharePoint 管理中心创建网站集时出错
- jquery - 在 Jquery / Ajax 中使用 for 循环动态创建行
- python - 通过 Python win32com 从 Outlook 中读取联系人详细信息
- node.js - 如何以编程方式使用节点 js 使用 gnupg 创建密钥对?
- javascript - 电子安装中止 - ECONNRESET
- ibm-cloud - 如何通过 REST API 检索资源组?
- java - 线程如何在 try-catch 块中被杀死?
- asp.net - 如何在 OnInit 函数中插入回调函数?