07:31Code a stopwatch using Python! ⏱
From the creator
#python #pythontutorial #pythoncourse 00:00:00 intro 00:00:16 pip install PyQt5 00:00:37 imports 00:01:56 class Stopwatch(QWidget) 00:02:28 if __name__ 00:03:54 START HERE 00:05:57 method declarations 00:06:55 initUI() 00:09:40 setStyleSheet() 00:12:28 signals and slots 00:13:33 methods definitions # Python PyQt5 Stopwatch import sys from PyQt5.QtWidgets import (QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout) from PyQt5.QtCore import QTimer, QTime, Qt class Stopwatch(QWidget): def __init__(self): super().__init__() self.time = QTime(0, 0, 0, 0) self.time_label = QLabel("00:00:00.00", self) self.start_button = QPushButton("Start", self) self.stop_button = QPushButton("Stop", self) self.reset_button = QPushButton("Reset", self) self.timer = QTimer(self) self.initUI() def initUI(self): self.setWindowTitle("Stopwatch") vbox = QVBoxLayout() vbox.addWidget(self.time_label) self.setLayout(vbox) self.time_label.setAlignment(Qt.AlignCenter) hbox = QHBoxLayout() hbox.addWidget(self.start_button) hbox.addWidget(self.stop_button) hbox.addWidget(self.reset_button) vbox.addLayout(hbox) self.setStyleSheet(""" QPushButton, QLabel{ padding: 20px; font-weight: bold; font-family: calibri;
Published 2024-08-02 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.





