-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.py
More file actions
43 lines (37 loc) · 975 Bytes
/
Timer.py
File metadata and controls
43 lines (37 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from PySide2.QtCore import *
from PySide2.QtWidgets import *
class Timer:
def __init__(self):
"""
Constructor
"""
self.time = QTime()
self.timer_label = QLabel()
self.timer = QTimer()
self.init_timer()
self.timer_paused = False
def init_timer(self):
"""
Initialize the timer
"""
self.time = QTime(0, 0, 0)
self.timer.start(1000)
self.timer_label.setText("00:00:00")
self.timer_paused = False
def pause_timer(self):
"""
Pause the timer
"""
self.timer_paused = True
def resume_timer(self):
"""
Resume the timer
"""
self.timer_paused = False
def timer_event(self):
"""
Event to timer trigged
"""
if not self.timer_paused:
self.time = self.time.addSecs(1)
self.timer_label.setText(self.time.toString("hh:mm:ss"))