src/eric7/EricWidgets/EricProcessDialog.py

branch
eric7
changeset 9958
a78b83d1062a
parent 9653
e67609152c5e
child 10423
299802979277
equal deleted inserted replaced
9957:0457d754fc9a 9958:a78b83d1062a
34 It starts a QProcess and displays a dialog that shows the output of the 34 It starts a QProcess and displays a dialog that shows the output of the
35 process. The dialog is modal, which causes a synchronized execution of 35 process. The dialog is modal, which causes a synchronized execution of
36 the process. 36 the process.
37 """ 37 """
38 38
39 def __init__(self, outputTitle="", windowTitle="", showProgress=False, parent=None): 39 def __init__(
40 self,
41 outputTitle="",
42 windowTitle="",
43 showProgress=False,
44 showInput=True,
45 combinedOutput=False,
46 parent=None,
47 ):
40 """ 48 """
41 Constructor 49 Constructor
42 50
43 @param outputTitle title for the output group 51 @param outputTitle title for the output group (defaults to "")
44 @type str 52 @type str (optional)
45 @param windowTitle title of the dialog 53 @param windowTitle title of the dialog (defaults to "")
46 @type str 54 @type str (optional)
47 @param showProgress flag indicating to show a progress bar 55 @param showProgress flag indicating to show a progress bar (defaults to False)
48 @type bool 56 @type bool (optional)
49 @param parent reference to the parent widget 57 @param showInput flag indicating to allow input to the process (defaults to
50 @type QWidget 58 True)
59 @type bool (optional)
60 @param combinedOutput flag indicating to show output of the stderr channel
61 in the main output pane (defaults to False)
62 @type bool (optional)
63 @param parent reference to the parent widget (defaults to None)
64 @type QWidget (optional)
51 """ 65 """
52 super().__init__(parent) 66 super().__init__(parent)
53 self.setupUi(self) 67 self.setupUi(self)
54 68
55 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) 69 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
65 self.setWindowTitle(windowTitle) 79 self.setWindowTitle(windowTitle)
66 if outputTitle: 80 if outputTitle:
67 self.outputGroup.setTitle(outputTitle) 81 self.outputGroup.setTitle(outputTitle)
68 self.__showProgress = showProgress 82 self.__showProgress = showProgress
69 self.progressBar.setVisible(self.__showProgress) 83 self.progressBar.setVisible(self.__showProgress)
84
85 self.__showInput = showInput
86 self.__combinedOutput = combinedOutput
87
88 if not self.__showInput:
89 self.inputGroup.setEnabled(False)
90 self.inputGroup.hide()
70 91
71 self.__process = None 92 self.__process = None
72 self.__progressRe = re.compile(r"""(\d{1,3})\s*%""") 93 self.__progressRe = re.compile(r"""(\d{1,3})\s*%""")
73 94
74 self.show() 95 self.show()
189 self.tr("Process Generation Error"), 210 self.tr("Process Generation Error"),
190 self.tr("<p>The process <b>{0}</b> could not be started.</p>").format( 211 self.tr("<p>The process <b>{0}</b> could not be started.</p>").format(
191 program 212 program
192 ), 213 ),
193 ) 214 )
194 else: 215 elif self.__showInput:
195 self.inputGroup.setEnabled(True) 216 self.inputGroup.setEnabled(True)
196 self.inputGroup.show() 217 self.inputGroup.show()
197 218
198 return procStarted 219 return procStarted
199 220
253 self.__process.readAllStandardError(), 274 self.__process.readAllStandardError(),
254 Preferences.getSystem("IOEncoding"), 275 Preferences.getSystem("IOEncoding"),
255 "replace", 276 "replace",
256 ) 277 )
257 278
258 self.errorGroup.show() 279 if self.__combinedOutput:
259 self.errors.insertPlainText(s) 280 self.resultbox.insertPlainText(s)
260 self.errors.ensureCursorVisible() 281 self.resultbox.ensureCursorVisible()
282 else:
283 self.errorGroup.show()
284 self.errors.insertPlainText(s)
285 self.errors.ensureCursorVisible()
261 286
262 QCoreApplication.processEvents() 287 QCoreApplication.processEvents()
263 288
264 def on_passwordCheckBox_toggled(self, isOn): 289 def on_passwordCheckBox_toggled(self, isOn):
265 """ 290 """

eric ide

mercurial