当前位置:网站首页>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边栏推荐
- Understand the principle of bytecode enhancement technology through the jvm-sandbox source code
- Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal
- Detailed explanation of event cycle
- 新手找陪驾要注意什么
- leetcode刷题:二叉树08(N叉树的最大深度)
- Emlog用户注册插件 价值80元
- Dry goods | detailed explanation of webshell Foundation
- 2020 Bioinformatics | TransformerCPI
- Touch your hand and bring you a commonjs specification
- Restore the subtlety of window position
猜你喜欢

Modstartblog modern personal blog system v5.2.0 source code download

疫情远程办公经验分享| 社区征文

leetcode刷题:二叉树06(对称二叉树)

leetcode刷题:二叉树09(二叉树的最小深度)

Select function variable column name in dplyr of R language

Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal

UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x98 in position 1093: illegal multibyte sequence

Rhcsa 04 - process management

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线

微信脑力比拼答题小程序_支持流量主带最新题库文件
随机推荐
架构训练毕业设计+总结
网络 - VXLAN
TCP-三次握手和四次挥手简单理解
Leetcode skimming: binary tree 04 (sequence traversal of binary tree)
Restore the subtlety of window position
[microservice openfeign] use openfeign to remotely call the file upload interface
Configuration and hot update of nocturnal simulator in hbuildx
Emlog用户注册插件 价值80元
leetcode刷题:二叉树07(二叉树的最大深度)
【云原生】那些看起来很牛X,原理却很简单的一行代码
leetcode刷题:二叉树08(N叉树的最大深度)
Leader: who uses redis expired monitoring to close orders and get out of here!
架构实战营 - 第 6 期 模块九之毕业设计
旭化成首次参展第五届中国国际进口博览会(5th CIIE)
leetcode刷题:二叉树06(对称二叉树)
西部数据绿盘、蓝盘、黑盘、红盘和紫盘有什么区别
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Redis: hash type data operation command
Operation of ES6
EIG在智利推出可再生能源平台Grupo Cerro