当前位置:网站首页>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
边栏推荐
- Haproxy cluster
- Xshell's ssh server rejected the password, failed to skip publickey authentication, and did not register with the server
- Iframe to only show a certain part of the page
- Detailed explanation of NPM installation and caching mechanism
- IO stream ----- open
- Data transmission in the network
- QQ get group settings
- Ternsort model integration summary
- BCD code Baidu Encyclopedia
- (August 9, 2021) example exercise of air quality index calculation (I)
猜你喜欢
netstat
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
Process communication and thread explanation
(August 9, 2021) example exercise of air quality index calculation (I)
MPLS experiment
Realize cross tenant Vnet connection through azure virtual Wan
Experiment 7. IPv6
Detailed explanation of classic process synchronization problems
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
Star leap plan | new projects are continuously being recruited! MSR Asia MSR Redmond joint research program invites you to apply!
随机推荐
How do std:: function and function pointer assign values to each other
01. Basics - MySQL overview
Exceptions and exception handling
How to use the mongodb ID array to get multiple documents- How to get multiple document using array of MongoDb id?
DVC use case (VI): Data Registry
The most robust financial products in 2022
(August 9, 2021) example exercise of air quality index calculation (I)
Introduction of network security research direction of Shanghai Jiaotong University
Realize cross tenant Vnet connection through azure virtual Wan
MPLS experiment
Attributes and methods in math library
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
Experiment 7. IPv6
Unity performance optimization reading notes - explore performance issues -profiler (2.1)
IO stream ----- open
Source code analysis of the implementation mechanism of multisets in guava class library
Foreach (system.out:: println) usage
priority_ queue
[solve the error of this pointing in the applet] SetData of undefined
Login operation (for user name and password)