38 lines
871 B
Python
Executable File
38 lines
871 B
Python
Executable File
import sys
|
|
from time import strftime
|
|
|
|
from PyQt6.QtCore import QTimer
|
|
from PyQt6.QtWidgets import QApplication, QLCDNumber, QVBoxLayout, QWidget
|
|
|
|
|
|
class Window(QWidget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setGeometry(100, 100, 800, 400)
|
|
self.setWindowTitle("Clock")
|
|
vbox = QVBoxLayout()
|
|
|
|
self.timer = QTimer()
|
|
self.timer.timeout.connect(self.update_clock)
|
|
self.timer.start(200)
|
|
|
|
self.lcd = QLCDNumber()
|
|
vbox.addWidget(self.lcd)
|
|
self.setLayout(vbox)
|
|
|
|
def update_clock(self) -> None:
|
|
time_ = strftime("%H:%M:%S")
|
|
self.lcd.setDigitCount(8)
|
|
self.lcd.display(time_)
|
|
|
|
|
|
def main():
|
|
app = QApplication(sys.argv)
|
|
window = Window()
|
|
window.show()
|
|
sys.exit(app.exec())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|