pyefun.核心支持库.时钟 module¶
提示
时钟
易语言的时钟组件
实现了 时钟周期事件
使用装饰器设置定时任务 函数内返回 false则停止时钟
1import unittest
2
3from .时钟 import *
4
5
6class Test时钟(unittest.TestCase):
7
8 def test_1(self):
9 pass
10
11 @时钟周期事件(时钟周期=1000)
12 def 定时任务():
13 print("定时任务")
14 # return True
15 return False
16
17 def test_2(self):
18 pass
19
20 def 定时任务():
21 print("定时任务")
22 # return True
23 return False
24 时钟(定时任务, 时钟周期=1000)
1 @时钟周期事件(时钟周期=1000)
2 def 定时任务():
3 print("定时任务")
4 # return True
5 return False
6
7 定时任务2运行状态 = True
8
9 def 定时任务2():
10 print(1111111111111,定时任务2运行状态)
11 return 定时任务2运行状态
12 # return False
13
14
15 时钟(定时任务2, 时钟周期=2000)
16
17 @时钟周期事件(时钟周期=5000)
18 def 定时任务3():
19 global 定时任务2运行状态
20 print("把时钟停止掉")
21 定时任务2运行状态 = False
22 return False