문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다: 사용자.
<source lang=python> import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import QTimer, QTime class MyWindow(QWidget): def __init__(self): super().__init__() self.timer = QTimer(self) self.timer.setInterval(0.5) self.timer.timeout.connect(self.timeout) self.setWindowTitle('QTimer') self.setGeometry(100, 100, 600, 280) layout = QVBoxLayout() self.lcd = QLCDNumber() self.lcd.display('') self.lcd.setDigitCount(15) subLayout = QHBoxLayout() self.btnStart = QPushButton("시작") self.btnStart.clicked.connect(self.onStartButtonClicked) self.btnStop = QPushButton("멈춤") self.btnStop.clicked.connect(self.onStopButtonClicked) layout.addWidget(self.lcd) subLayout.addWidget(self.btnStart) subLayout.addWidget(self.btnStop) layout.addLayout(subLayout) self.btnStop.setEnabled(False) self.setLayout(layout) def onStartButtonClicked(self): self.timer.start() self.btnStop.setEnabled(True) self.btnStart.setEnabled(False) def onStopButtonClicked(self): self.timer.stop() self.btnStop.setEnabled(False) self.btnStart.setEnabled(True) def timeout(self): sender = self.sender() currentTime = QTime.currentTime().toString("hh:mm:ss,zzz") if id(sender) == id(self.timer): self.lcd.display(currentTime) if __name__ == "__main__": app = QApplication(sys.argv) myWindow = MyWindow() myWindow.show() sys.exit(app.exec_()) </source> [[Category:python]]
문서 저장 미리 보기 차이 보기 취소