当前位置:网站首页>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边栏推荐
- Talking about what a high-quality little red book copy needs to have
- 浅谈一篇优质的小红书文案需要具备什么
- 博朗与Virgil Abloh于2021年为纪念博朗品牌100周年而联合打造的“功能性艺术”将在博物馆展出Abloh作品期间首次亮相
- 多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者
- Rhcsa 04 - process management
- 微信脑力比拼答题小程序_支持流量主带最新题库文件
- Configuration and hot update of nocturnal simulator in hbuildx
- RHCSA 01 - 创建分区与文件系统
- 统计遗传学:第三章,群体遗传
- Touch your hand and bring you a commonjs specification
猜你喜欢

R语言中如何查看已安装的R包

leetcode刷题:二叉树04(二叉树的层序遍历)

How to telecommute more efficiently | community essay solicitation

Leetcode brush questions: binary tree 05 (flip binary tree)

Redis: hash type data operation command

【微服务|openfeign】@FeignClient详解

2021 RSC | Drug–target affinity prediction using graph neural network and contact maps

RHCSA 04 - 进程管理

虚拟商品帐号交易平台源码_支持个人二维码收款

Graduation project: design seckill e-commerce system
随机推荐
Configuration and hot update of nocturnal simulator in hbuildx
(指針)自己寫一個比較字符串大小的函數,功能與strcmp類似。
Katalon uses script to query list size
leetcode刷题:二叉树07(二叉树的最大深度)
毕业设计项目
Unity资源路径
MySQL JDBC编程
[microservices openfeign] two degradation methods of feign | fallback | fallbackfactory
FT2000+下LPC中断绑核使用说明
How to add custom API objects in kubernetes (1)
ctf-pikachu-XSS
Wechat official account infinite callback authorization system source code
Unity Resource path
Application scheme of Puyuan ds1000z series digital oscilloscope in communication principle experiment
leetcode刷题:二叉树04(二叉树的层序遍历)
十字路口通行优先权,十字路口通行规则图解
沃博联结束战略评估,决定保留表现优异的博姿业务
R语言dplyr中的Select函数变量列名
C语言双向链表初版
Emlog user registration plug-in is worth 80 yuan