{"id":160,"date":"2026-04-24T15:16:49","date_gmt":"2026-04-24T15:16:49","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/d_harkless\/?p=160"},"modified":"2026-04-24T15:16:49","modified_gmt":"2026-04-24T15:16:49","slug":"free-friday-4-24-26","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/d_harkless\/2026\/04\/24\/free-friday-4-24-26\/","title":{"rendered":"Free Friday 4\/24\/26"},"content":{"rendered":"\n<p>Today in class, I made a stopwatch.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"340\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-8.png\" alt=\"\" class=\"wp-image-161\" style=\"aspect-ratio:1.879502205833937;width:424px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-8.png 639w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-8-300x160.png 300w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"343\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-9.png\" alt=\"\" class=\"wp-image-162\" style=\"width:427px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-9.png 643w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-9-300x160.png 300w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"341\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-10.png\" alt=\"\" class=\"wp-image-163\" style=\"width:434px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-10.png 643w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-10-300x159.png 300w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/figure>\n\n\n\n<p>This is the code that shows the Layout of the stopwatch. The time is vertical and centered. The start, stop, and reset buttons are horizontal. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ndef initUI(self):\n        self.setWindowTitle(\"Stopwatch\")\n\n        vbox = QVBoxLayout()\n        vbox.addWidget(self.time_label)\n       \n        self.setLayout(vbox)\n\n        self.time_label.setAlignment(Qt.AlignCenter)\n\n        hbox = QHBoxLayout()\n\n        hbox.addWidget(self.start_button)\n        hbox.addWidget(self.stop_button)\n        hbox.addWidget(self.reset_button)\n\n        vbox.addLayout(hbox)\n<\/code><\/pre>\n\n\n\n<p>This is the style for the stopwatch.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>self.setStyleSheet(\"\"\"\n            QPushButton, QLabel{\n                padding: 20px;\n                font-weight: bold;\n                font-family: calibri;\n            }\n            QPushButton{\n                font-size: 50px;\n            }\n            QLabel{\n                font-size: 120px;\n                background-color: hsl(200, 100%, 85%);\n                border-radius: 20px;\n            }\n        \"\"\")<\/code><\/pre>\n\n\n\n<p>This the code that starts the time, stops it, resets it, and updates it, and the format.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def start(self):\n        self.timer.start(10)\n\n    def stop(self):\n        self.timer.stop()\n\n    def reset(self):\n        self.timer.stop()\n        self.time = QTime(0, 0, 0, 0)\n        self.time_label.setText(self.format_time(self.time))\n\n    def format_time(self, time):\n        hours = time.hour()\n        minutes = time.minute()\n        seconds = time.second()\n        milliseconds = time.msec() \/\/ 10\n        return f\"{hours:02}:{minutes:02}:{seconds:02}.{milliseconds:02}\"\n\n    def update_display(self):\n        self.time = self.time.addMSecs(10)\n        self.time_label.setText(self.format_time(self.time))<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today in class, I made a stopwatch. This is the code that shows the Layout of the stopwatch. The time is vertical and centered. The start, stop, and reset buttons are horizontal. This is the style for the stopwatch. This the code that starts the time, stops it, resets it, and updates it, and the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":164,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/160\/revisions\/164"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}