from PyQt4 import QtCore, QtGui from time import sleep import sys, os class MyCustomWidget(QtGui.QWidget): def __init__(self, parent=None): super(MyCustomWidget, self).__init__(parent) layout = QtGui.QVBoxLayout(self) # Create a progress bar and a button and add them to the main layout self.progressBar = QtGui.QProgressBar(self) self.progressBar.setRange(0,1) layout.addWidget(self.progressBar) button = QtGui.QPushButton("Start", self) layout.addWidget(button) button.clicked.connect(self.onStart) self.myLongTask = TaskThread() self.myLongTask.taskFinished.connect(self.onFinished) def onStart(self): self.progressBar.setRange(0,0) self.myLongTask.start() def onFinished(self): # Stop the pulsation self.progressBar.setRange(0,1) self.progressBar.setValue(1) class TaskThread(QtCore.QThread): taskFinished = QtCore.pyqtSignal() def run(self): print "hello world"*100000 self.taskFinished.emit() if __name__ == "__main__": app = QtGui.QApplication(sys.argv) window = MyCustomWidget() window.resize(640, 480) window.show() sys.exit(app.exec_())
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
10 | QML 및 Window 투명처리 | makersweb | 2015.04.22 | 4243 |
9 | [pyqt4]QTimer 예제 - 버튼을 누르면 3초후 함수 또는 메소드 호출 | makersweb | 2015.04.01 | 9886 |
8 | Python + QML with PyQt4 | makersweb | 2015.03.24 | 7995 |
7 | [PyQt4]개발 프로그램 버전표시 메세지 박스 | pjk | 2014.09.02 | 7787 |
6 | [PyQt4]여러가지 버튼 예제 | pjk | 2014.08.29 | 14026 |
» | [PyQt4]스레드 및 ProgressBar 예제 코드 | pjk | 2014.08.26 | 8270 |
4 | [PyQt4]multiprocess 예제 코드 | pjk | 2014.08.26 | 8171 |
3 | [PyQt4]마우스 클릭 이벤트 예제 코드 | pjk | 2014.08.26 | 6791 |
2 | [PyQt4]폴더 또는 파일을 드레그하여 그 경로를 LineEdit로 가져오기 | pjk | 2014.08.22 | 13567 |
1 | [PyQt4]윈도우창에 별 찍기 예제 | pjk | 2014.08.19 | 8146 |