import sys
import time
from PyQt5.QtWidgets import QProgressDialog, QApplication, QMainWindow, QMessageBox
from PyQt5.QtCore import *
from main_win import Ui_MainWindow
from PyQt5.QtCore import Qt
class Worker(QThread):
progressBarValue = pyqtSignal(int) # 更新进度条
RANGE = 11
def __init__(self, main_win):
super().__init__(parent=None)
self.main_win = main_win
def get_range(self):
return self.RANGE
def run(self):
for i in range(0, self.get_range()):
time.sleep(1)
self.progressBarValue.emit(i) # 发送进度条的值 信号
if self.main_win.progress.wasCanceled():
self.progressBarValue.emit(-1)
return
class MainWin(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.btn_start.clicked.connect(self.btn_click)
self.show()
PyQt5 使用ProgressDialog展示异步任务进度
最新推荐文章于 2024-10-10 10:35:12 发布