当前位置:网站首页>Kivy教程之 08 倒计时App实现timer调用(教程含源码)
Kivy教程之 08 倒计时App实现timer调用(教程含源码)
2022-07-04 12:32:00 【知识大胖】
实战需求
倒计时App实现timer调用
运行效果
解决方案
1.引入Clock组件
from kivy.clock import Clock
2. Clock组件实现timer
def on_start(self):
Clock.schedule_interval(self.update, 0)
3. update回调更新界面
def update(self, nap):
# print('update')
if self.sw_started:
self.sw_seconds += nap
m, s = divmod(self.sw_seconds, 60)
self.root.ids.time.text = ('%02d:%02d.[size=40]%02d[/size]' %(int(m), int(s), int(s * 100 % 100)))
通过on_press来指定响应函数
完整代码
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.utils import get_co
边栏推荐
- C language memory layout
- Dos and path
- Clockwise rotation method of event arrangement -- PHP implementation
- A few words explain redis cache penetration, breakdown, avalanche, and redis sentinel
- Haproxy cluster
- MPLS experiment
- LxC shared directory permission configuration
- Ultimate bug finding method - two points
- Single spa, Qiankun, Friday access practice
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
猜你喜欢
What if the chat record is gone? How to restore wechat chat records on Apple Mobile
Reptile learning 3 (winter vacation learning)
JD home programmers delete databases and run away. Talk about binlog, the killer of MySQL data backup
MySQL advanced review
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 5
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
Force buckle 142 Circular linked list II
CSDN documentation specification
MPLS experiment
Reptile learning winter vacation series (2)
随机推荐
Awk getting started to proficient series - awk quick start
LVS load balancing cluster deployment - Dr direct routing mode
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
LxC shared directory addition and deletion
The detailed installation process of Ninja security penetration system (Ninjitsu OS V3). Both old and new VM versions can be installed through personal testing, with download sources
QQ get group settings
Pat 1059 prime factors (25 points) prime table
MySQL performance optimization index
QQ group administrators
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
Using terminal connection in different modes of virtual machine
The most robust financial products in 2022
[the way of programmer training] - 2 Perfect number calculation
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
Video analysis
AI should take code agriculture? Deepmind offers a programming version of "Alpha dog" alphacode that surpasses nearly half of programmers!
Day01 preliminary packet capture
Interview question MySQL transaction (TCL) isolation (four characteristics)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9