Pyqt5 ProgressBar
DB CAFE
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
PyQt5 진행바[편집]
from PyQt5.QtWidgets import QWidget, QProgressBar, QPushButton, QApplication, QHBoxLayout, QMessageBox
from PyQt5.QtCore import QBasicTimer
import sys
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
layout = QHBoxLayout()
self.pbar = QProgressBar(self)
self.pbar.setGeometry(10, 40, 250, 25)
self.startbtn = QPushButton('Start', self)
self.stopbtn = QPushButton('Stop', self)
self.resetbtn = QPushButton('Reset', self)
layout.addWidget(self.startbtn)
layout.addWidget(self.stopbtn)
layout.addWidget(self.resetbtn)
self.startbtn.clicked.connect(self.start)
self.stopbtn.clicked.connect(self.stop)
self.resetbtn.clicked.connect(self.reset)
self.setLayout(layout)
self.timer = QBasicTimer()
self.step = 0
self.setGeometry(300, 300, 280, 170)
self.setWindowTitle('PyQt5')
self.show()
def timerEvent(self, event):
if self.step >= 100:
self.timer.stop()
QMessageBox.question(self, 'Event', 'Finish')
self.step += 1
self.pbar.setValue(self.step)
def start(self):
self.timer.start(100, self)
def stop(self):
self.timer.stop()
def reset(self):
self.timer.stop()
self.step = 0
self.pbar.setValue(self.step)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())