src/eric7/EricWidgets/EricProcessDialog.py

branch
eric7
changeset 10933
95a15b70f7bb
parent 10835
9117c08e4707
child 11090
f5f5f5803935
equal deleted inserted replaced
10932:82de5109035a 10933:95a15b70f7bb
16 QProcessEnvironment, 16 QProcessEnvironment,
17 Qt, 17 Qt,
18 QTimer, 18 QTimer,
19 pyqtSlot, 19 pyqtSlot,
20 ) 20 )
21 from PyQt6.QtGui import QFont
21 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLineEdit 22 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLineEdit
22 23
23 from eric7 import Preferences
24 from eric7.EricUtilities import strToQByteArray 24 from eric7.EricUtilities import strToQByteArray
25 from eric7.EricWidgets import EricMessageBox 25 from eric7.EricWidgets import EricMessageBox
26 26
27 from .Ui_EricProcessDialog import Ui_EricProcessDialog 27 from .Ui_EricProcessDialog import Ui_EricProcessDialog
28 28
41 outputTitle="", 41 outputTitle="",
42 windowTitle="", 42 windowTitle="",
43 showProgress=False, 43 showProgress=False,
44 showInput=True, 44 showInput=True,
45 combinedOutput=False, 45 combinedOutput=False,
46 monospacedFont=None,
47 encoding="utf-8",
46 parent=None, 48 parent=None,
47 ): 49 ):
48 """ 50 """
49 Constructor 51 Constructor
50 52
58 True) 60 True)
59 @type bool (optional) 61 @type bool (optional)
60 @param combinedOutput flag indicating to show output of the stderr channel 62 @param combinedOutput flag indicating to show output of the stderr channel
61 in the main output pane (defaults to False) 63 in the main output pane (defaults to False)
62 @type bool (optional) 64 @type bool (optional)
65 @param monospacedFont font to be used (should be a monospaced one) (defaults
66 to None)
67 @type QFont
68 @param encoding encoding used for the communication with the process (defaults
69 to "utf-8")
70 @type str (optional)
63 @param parent reference to the parent widget (defaults to None) 71 @param parent reference to the parent widget (defaults to None)
64 @type QWidget (optional) 72 @type QWidget (optional)
65 """ 73 """
66 super().__init__(parent) 74 super().__init__(parent)
67 self.setupUi(self) 75 self.setupUi(self)
68 76
69 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) 77 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
70 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) 78 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
71 79
72 font = Preferences.getEditorOtherFonts("MonospacedFont") 80 if monospacedFont is None:
73 self.resultbox.setFontFamily(font.family()) 81 monospacedFont = QFont("Monospace")
74 self.resultbox.setFontPointSize(font.pointSize()) 82 self.resultbox.setFontFamily(monospacedFont.family())
75 self.errors.setFontFamily(font.family()) 83 self.resultbox.setFontPointSize(monospacedFont.pointSize())
76 self.errors.setFontPointSize(font.pointSize()) 84 self.errors.setFontFamily(monospacedFont.family())
85 self.errors.setFontPointSize(monospacedFont.pointSize())
86
87 self.__ioEncoding = encoding
77 88
78 if windowTitle: 89 if windowTitle:
79 self.setWindowTitle(windowTitle) 90 self.setWindowTitle(windowTitle)
80 if outputTitle: 91 if outputTitle:
81 self.outputGroup.setTitle(outputTitle) 92 self.outputGroup.setTitle(outputTitle)
245 output pane. 256 output pane.
246 """ 257 """
247 if self.__process is not None: 258 if self.__process is not None:
248 s = str( 259 s = str(
249 self.__process.readAllStandardOutput(), 260 self.__process.readAllStandardOutput(),
250 Preferences.getSystem("IOEncoding"), 261 self.__ioEncoding,
251 "replace", 262 "replace",
252 ) 263 )
253 if self.__showProgress: 264 if self.__showProgress:
254 match = self.__progressRe.search(s) 265 match = self.__progressRe.search(s)
255 if match: 266 if match:
270 error pane. 281 error pane.
271 """ 282 """
272 if self.__process is not None: 283 if self.__process is not None:
273 s = str( 284 s = str(
274 self.__process.readAllStandardError(), 285 self.__process.readAllStandardError(),
275 Preferences.getSystem("IOEncoding"), 286 self.__ioEncoding,
276 "replace", 287 "replace",
277 ) 288 )
278 289
279 if self.__combinedOutput: 290 if self.__combinedOutput:
280 self.resultbox.insertPlainText(s) 291 self.resultbox.insertPlainText(s)

eric ide

mercurial