赞
踩
loading.gif是从 http://www.sucaijishi.com/gif-11-57-1.html找的图
class LoadingProgress(QtWidgets.QDialog): update_signal = QtCore.pyqtSignal(bool) def __init__(self, parent=None): super(LoadingProgress, self).__init__(parent) self.value = 0 self.update_signal.connect(self.update_progress) vbox = QtWidgets.QVBoxLayout(self) self.steps = [f"连接服务器中({TIMEOUT}s)...", "发送数据中...", "接收数据中...", "解析数据中..."] self.movie_label = QtWidgets.QLabel() self.movie = QtGui.QMovie("images/loading.gif") self.movie_label.setMovie(self.movie) self.movie.start() self.progress_label = QtWidgets.QLabel() self.label_update() vbox.addWidget(self.movie_label) vbox.addWidget(self.progress_label) self.setLayout(vbox) # self.exec_() def label_update(self): self.progress_label.setText(self.steps[self.value]) def update_progress(self, boolean: bool) -> None: self.value += 1 if boolean and self.value < len(self.steps): self.label_update() else: self.close()
阻塞调用:
self.exec_()
非阻塞调用:
self.show()
源代码就不发了, 今天就发v2.6
的更新, 顺带发了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。