{"id":8345,"date":"2019-10-28T22:37:01","date_gmt":"2019-10-28T13:37:01","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=8345"},"modified":"2020-05-28T10:04:50","modified_gmt":"2020-05-28T01:04:50","slug":"pyqt5-timer","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=8345","title":{"rendered":"[PyQt5] \ud0c0\uc774\uba38(Timer) \uc0ac\uc6a9\ud558\uae30"},"content":{"rendered":"<p>PyQt\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 \ud0c0\uc774\uba38\ub97c \uc0ac\uc6a9\ud574 \uac04\ub2e8\ud55c \ub514\uc9c0\ud138 \uc2dc\uacc4\uc5d0 \ub300\ud55c UI\ub97c \uad6c\uc131\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \ub514\uc9c0\ud138 \uc2dc\uacc4\uc5d0 \ub300\ud55c \ud45c\ud604\uc740 QLCDNumber\ub77c\ub294 \uc704\uc82f\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uc544\ub798\ub294 \ucd5c\uc885 \uc2e4\ud589 \uacb0\uacfc\uc785\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/10\/PtQt5_Timer.png\" alt=\"\" width=\"1424\" height=\"828\" class=\"aligncenter size-full wp-image-8356\" \/><\/p>\n<p>\uc2dc\uc791 \ubc84\ud2bc\uc744 \ud074\ub9ad\ud558\uba74, \uc77c\uc815\ud55c \uc8fc\uae30\ub85c \uc2dc\uac04 \ud45c\uc2dc\uac00 \ubcc0\uacbd\ub418\uba70 \uba48\ucda4 \ubc84\ud2bc\uc744 \ud074\ub9ad\ud558\uba74 \uc2dc\uac04 \ud45c\uc2dc\uc5d0 \ub300\ud55c \uac31\uc2e0\uc744 \uc911\ub2e8\ud569\ub2c8\ub2e4. \uba48\ucda4 \uc0c1\ud0dc\uc5d0\uc11c \ub2e4\uc2dc \uc2dc\uc791 \ubc84\ud2bc\uc744 \ud074\ub9ad\ud558\uba74 \uc2dc\uac04 \ud45c\uc2dc\uac00 \ubcc0\uacbd\ub418\uae30 \uc2dc\uc791\ud569\ub2c8\ub2e4. \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport sys\r\nfrom PyQt5.QtWidgets import *\r\nfrom PyQt5.QtCore import QTimer, QTime\r\n\r\nclass MyWindow(QWidget):\r\n    def __init__(self):\r\n        super().__init__()\r\n\r\n        self.timer = QTimer(self)\r\n        self.timer.setInterval(1000)\r\n        self.timer.timeout.connect(self.timeout)\r\n\r\n        self.setWindowTitle('QTimer')\r\n        self.setGeometry(100, 100, 600, 280)\r\n \r\n        layout = QVBoxLayout()\r\n \r\n        self.lcd = QLCDNumber()\r\n        self.lcd.display('')\r\n        self.lcd.setDigitCount(8)\r\n\r\n        subLayout = QHBoxLayout()\r\n        \r\n        self.btnStart = QPushButton(\"\uc2dc\uc791\")\r\n        self.btnStart.clicked.connect(self.onStartButtonClicked)\r\n \r\n        self.btnStop = QPushButton(\"\uba48\ucda4\")\r\n        self.btnStop.clicked.connect(self.onStopButtonClicked)\r\n \r\n        layout.addWidget(self.lcd)\r\n        \r\n        subLayout.addWidget(self.btnStart)\r\n        subLayout.addWidget(self.btnStop)\r\n        layout.addLayout(subLayout)\r\n \r\n        self.btnStop.setEnabled(False)\r\n\r\n        self.setLayout(layout)        \r\n\r\n    def onStartButtonClicked(self):\r\n        self.timer.start()\r\n        self.btnStop.setEnabled(True)\r\n        self.btnStart.setEnabled(False)\r\n\r\n    def onStopButtonClicked(self):\r\n        self.timer.stop()\r\n        self.btnStop.setEnabled(False)\r\n        self.btnStart.setEnabled(True)\r\n\r\n    def timeout(self):\r\n        sender = self.sender()\r\n        currentTime = QTime.currentTime().toString(\"hh:mm:ss\")\r\n\r\n        if id(sender) == id(self.timer):\r\n            self.lcd.display(currentTime)\r\n\r\nif __name__ == \"__main__\":\r\n    app = QApplication(sys.argv)\r\n    myWindow = MyWindow()\r\n    myWindow.show()\r\n    sys.exit(app.exec_())\r\n<\/pre>\n<p>\uc55e\uc11c \uc5b8\uae09\ud55c \ud0c0\uc774\uba38\uc758 \uac31\uc2e0 \uc2dc\uac04 \uc8fc\uae30\ub294 QTimer\uc758 setInterval \ud568\uc218\ub85c \uc9c0\uc815\ud558\uba70 \ub2e8\uc704\ub294 ms\ub85c\uc368, 1000\uc774 1\ucd08\uc5d0 \ud574\ub2f9\ud569\ub2c8\ub2e4. \ud0c0\uc774\uba38\uc5d0 \ub300\ud55c \uac31\uc2e0 \uc2dc\uc791\uacfc \uc911\uc9c0\ub294 \uac01\uac01 start\uc640 stop\uc785\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PyQt\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 \ud0c0\uc774\uba38\ub97c \uc0ac\uc6a9\ud574 \uac04\ub2e8\ud55c \ub514\uc9c0\ud138 \uc2dc\uacc4\uc5d0 \ub300\ud55c UI\ub97c \uad6c\uc131\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \ub514\uc9c0\ud138 \uc2dc\uacc4\uc5d0 \ub300\ud55c \ud45c\ud604\uc740 QLCDNumber\ub77c\ub294 \uc704\uc82f\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uc544\ub798\ub294 \ucd5c\uc885 \uc2e4\ud589 \uacb0\uacfc\uc785\ub2c8\ub2e4. \uc2dc\uc791 \ubc84\ud2bc\uc744 \ud074\ub9ad\ud558\uba74, \uc77c\uc815\ud55c \uc8fc\uae30\ub85c \uc2dc\uac04 \ud45c\uc2dc\uac00 \ubcc0\uacbd\ub418\uba70 \uba48\ucda4 \ubc84\ud2bc\uc744 \ud074\ub9ad\ud558\uba74 \uc2dc\uac04 \ud45c\uc2dc\uc5d0 \ub300\ud55c \uac31\uc2e0\uc744 \uc911\ub2e8\ud569\ub2c8\ub2e4. \uba48\ucda4 \uc0c1\ud0dc\uc5d0\uc11c \ub2e4\uc2dc \uc2dc\uc791 \ubc84\ud2bc\uc744 \ud074\ub9ad\ud558\uba74 \uc2dc\uac04 \ud45c\uc2dc\uac00 \ubcc0\uacbd\ub418\uae30 \uc2dc\uc791\ud569\ub2c8\ub2e4. \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. import sys from PyQt5.QtWidgets &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=8345\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[PyQt5] \ud0c0\uc774\uba38(Timer) \uc0ac\uc6a9\ud558\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[131,1],"tags":[],"class_list":["post-8345","post","type-post","status-publish","format-standard","hentry","category-python","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8345"}],"version-history":[{"count":4,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8345\/revisions"}],"predecessor-version":[{"id":14086,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8345\/revisions\/14086"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}