-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.py
More file actions
42 lines (27 loc) · 923 Bytes
/
Clock.py
File metadata and controls
42 lines (27 loc) · 923 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
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel
from PyQt5.QtGui import QFont
from PyQt5.QtCore import QTimer, QTime, Qt
class Digital(QWidget):
def __init__(self):
super(Digital, self).__init__()
layout = QVBoxLayout()
fnt = QFont('Open Sans', 120, QFont.Bold)
self.lbl = QLabel()
self.lbl.setAlignment(Qt.AlignCenter)
self.lbl.setFont(fnt)
layout.addWidget(self.lbl)
self.setLayout(layout)
timer = QTimer(self)
timer.timeout.connect(self.showTime)
timer.start(1000) # update every second
self.showTime()
def showTime(self):
currentTime = QTime.currentTime()
displayTxt = currentTime.toString('hh:mm:ss')
print(displayTxt)
self.lbl.setText(displayTxt)
app = QApplication(sys.argv)
demo = Digital()
demo.show()
app.exit(app.exec_())