from PyQt5 import uic
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import datetime
import time
CalUI = '../poor_timer/timer_gui.ui'
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self, None)
uic.loadUi(CalUI, self)
self.timer = QTimer(self)
self.timer.timeout.connect(self.timeout)
self.lcdNumber.setDigitCount(8)
# 처음 값 세팅은 45분 15분 쉬기
self.lcdNumber.display('0')
# 알람끄기/ 공부 시작/ 공부 멈춤
self.pushButton.clicked.connect(self.onStartButtonClicked)
def onStartButtonClicked(self):
self.timer.start()
def timeout(self):
sender = self.sender()
for i in range(5):
currentTime = str(i)
self.lcdNumber.display(currentTime)
time.sleep(1)
if __name__ == '__main__':
app = QApplication(sys.argv)
main_dialog = MainWindow()
main_dialog.show()
app.exec_()
`제가 파이썬과 pyqt5을 이용하여 스탑워치를 만들고 있는데 한 가지 문제점이 있어서 질문하게 되었습니다.
(일단 5초로 설정)스탑워치를 시작 버튼을 누르면 gui화면에 0 -> 1 -> 2 -> 3 -> 4 -> 5가 순차적으로 실행되는 그런 코드를 짜고 싶은데 제가 짠 코드에서는 0하고 몇 초 있다가 바로 5로 출력되고 있습니다. 혹시 쓰레드에 대해 문제가 있어서 이런 오류가 발생하나요? 아니면 다른 문제점이 있나요?
몇 일 째 고민하고 있지만 풀리지가 않네요. 제발 도와주세요.