当前位置:网站首页>Kivy教程之 07 组件和属性绑定实现按钮button点击修改label组件(教程含源码)
Kivy教程之 07 组件和属性绑定实现按钮button点击修改label组件(教程含源码)
2022-07-04 03:53:00 【知识大胖】
实战需求
组件和属性绑定实现按钮button点击修改label组件
运行效果
解决方案
1. 给label组件添加id
Label:
id: time
text: 'format:[b]00[/b]:00:00'
markup: True
2. 我们通过id修改label的文本
self.root.ids.time.text = "hello"
3. 添加button组件
Button:
id: start_stop
text: 'Start'
font_size: 25
bold: True
border: (2, 2, 2, 2)
on_press: app.start()
通过on_press来指定响应函数
4. 编写响应函数
def start(self):
self.root.ids.time.text = "hello"
完整代码
from kivy.app import App
from kivy.lang import Builder
from kivy.core.windo
边栏推荐
猜你喜欢
Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal
旭化成首次参展第五届中国国际进口博览会(5th CIIE)
Redis: hash type data operation command
深入解析结构化异常处理(SEH) - by Matt Pietrek
EventBridge 在 SaaS 企业集成领域的探索与实践
Unity draws the trajectory of pinball and billiards
RPC技术
微信脑力比拼答题小程序_支持流量主带最新题库文件
一个漂亮的API文档生成工具
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x98 in position 1093: illegal multibyte sequence
随机推荐
VIM add interval annotation correctly
ctf-pikachu-XSS
tdk-lambda电源主要应用
C语言单向链表练习
“找工作不要太在意工资”,这是我听过最大的谎言
领导:谁再用redis过期监听实现关闭订单,立马滚蛋!
EIG在智利推出可再生能源平台Grupo Cerro
Touch and take you to implement an EventEmitter
Use NRM and NVM to manage your NPM source and node versions
RPC技术
I.MX6U-ALPHA开发板(C语言版本LED驱动实验)
Redis:集合Set类型数据的操作命令
Leetcode 121 best time to buy and sell stock (simple)
Apple CMS imitation watermelon video atmospheric response video template source code
Redis:哈希hash类型数据操作命令
Redis: hash type data operation command
leetcode刷题:二叉树05(翻转二叉树)
Flink learning 7: application structure
Detailed explanation of event cycle
DP83848+网线热拔插