Sun, 08 Dec 2019 13:07:46 +0100
E5ProcessDialog: added the capability to show a progress bar.
eric6/E5Gui/E5ProcessDialog.py | file | annotate | diff | comparison | revisions | |
eric6/E5Gui/E5ProcessDialog.ui | file | annotate | diff | comparison | revisions |
--- a/eric6/E5Gui/E5ProcessDialog.py Sun Dec 08 12:38:34 2019 +0100 +++ b/eric6/E5Gui/E5ProcessDialog.py Sun Dec 08 13:07:46 2019 +0100 @@ -9,6 +9,7 @@ import os +import re from PyQt5.QtCore import ( QProcess, QTimer, pyqtSlot, Qt, QCoreApplication, QProcessEnvironment @@ -31,7 +32,8 @@ shows the output of the process. The dialog is modal, which causes a synchronized execution of the process. """ - def __init__(self, outputTitle="", windowTitle="", parent=None): + def __init__(self, outputTitle="", windowTitle="", showProgress=False, + parent=None): """ Constructor @@ -39,6 +41,8 @@ @type str @param windowTitle title of the dialog @type str + @param showProgress flag indicating to show a progress bar + @type bool @param parent reference to the parent widget @type QWidget """ @@ -52,8 +56,11 @@ self.setWindowTitle(windowTitle) if outputTitle: self.outputGroup.setTitle(outputTitle) + self.__showProgress = showProgress + self.progressBar.setVisible(self.__showProgress) self.__process = None + self.__progressRe = re.compile(r"""(\d{1,3})\s*%""") self.show() QCoreApplication.processEvents() @@ -206,6 +213,13 @@ s = str(self.__process.readAllStandardOutput(), Preferences.getSystem("IOEncoding"), 'replace') + if self.__showProgress: + match = self.__progressRe.search(s) + if match: + progress = int(match.group(1)) + self.progressBar.setValue(progress) + if not s.endswith("\n"): + s = s + "\n" self.resultbox.insertPlainText(s) self.resultbox.ensureCursorVisible()
--- a/eric6/E5Gui/E5ProcessDialog.ui Sun Dec 08 12:38:34 2019 +0100 +++ b/eric6/E5Gui/E5ProcessDialog.ui Sun Dec 08 13:07:46 2019 +0100 @@ -6,14 +6,14 @@ <rect> <x>0</x> <y>0</y> - <width>593</width> - <height>499</height> + <width>600</width> + <height>500</height> </rect> </property> <property name="sizeGripEnabled"> <bool>true</bool> </property> - <layout class="QVBoxLayout"> + <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QGroupBox" name="outputGroup"> <property name="sizePolicy"> @@ -40,6 +40,13 @@ </widget> </item> <item> + <widget class="QProgressBar" name="progressBar"> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item> <widget class="QLabel" name="statusLabel"/> </item> <item>