![PyQt5 예제 - QProgressDialog](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FY6GXS%2FbtsyUdSHQda%2FCYLUgNdD4BXvZSwq5E4w81%2Fimg.png)
PyQt5 예제 - QProgressDialogQt/PyQt5 강좌2023. 10. 22. 05:36
Table of Contents
반응형
간단한 QProgressDialog 예제 입니다.
2022. 8. 14 최초작성
실행하면 두 개의 버튼이 보입니다.
“QProgressDialog 보여주기”를 클릭하면 QProgressDialog를 보여줍니다.
“QProgressDialog 숨기기”를 클릭하면 QProgressDialog가 사라집니다.
전체 소스 코드입니다.
import sys from PyQt5.QtWidgets import QHBoxLayout, QPushButton, QProgressDialog, QDialog, QApplication from PyQt5.QtCore import Qt class MainDialog(QDialog): def __init__(self): super().__init__() horizontal_layout = QHBoxLayout() self.Button1 = QPushButton('QProgressDialog 보여주기', self) self.Button1.clicked.connect(self.generate) self.Button2 = QPushButton('QProgressDialog 숨기기', self) self.Button2.clicked.connect(self.hide) horizontal_layout.addWidget(self.Button1) horizontal_layout.addWidget(self.Button2) self.setLayout(horizontal_layout) self.Button2.setEnabled(False) def generate(self): self.Button1.setEnabled(False) self.Button2.setEnabled(True) self.progress = QProgressDialog('잠시만 기다리세요', '', 0, 0, self) self.progress.setWindowTitle("진행중...") self.progress.setWindowFlags(Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint) # self.progress.setWindowModality(Qt.WindowModal) # 주석을 해제하면 항상 모든 윈도우보다 상위에 존재하게 됩니다. self.progress.setCancelButton(None) self.progress.show() def hide(self): self.Button1.setEnabled(True) self.Button2.setEnabled(False) self.progress.hide() if __name__ == '__main__': app = QApplication(sys.argv) dlg = MainDialog() dlg.show() app.exec_() |
반응형
'Qt > PyQt5 강좌' 카테고리의 다른 글
PyQt5 예제 - QTreeView으로 json 로드하기 및 저장하기 (0) | 2023.10.22 |
---|---|
PyQt5 예제 - QListWidget (0) | 2023.10.22 |
PyQt5 예제 - connect에서 slot 함수에 아규먼트 전달하기 (0) | 2023.10.22 |
PyQt5 예제 - QStackedWidget (0) | 2023.10.22 |
PyQt5 예제 - FlowLayout (0) | 2023.10.22 |