--- a/ProjectFlask/FlaskCommandDialog.py Sat May 29 15:04:41 2021 +0200 +++ b/ProjectFlask/FlaskCommandDialog.py Sun May 30 17:33:37 2021 +0200 @@ -7,10 +7,10 @@ Module implementing a dialog to run a flask command and show its output. """ -from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer -from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton +from PyQt6.QtCore import pyqtSlot, Qt, QProcess, QTimer +from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton -from E5Gui import E5MessageBox +from EricWidgets import EricMessageBox from .Ui_FlaskCommandDialog import Ui_FlaskCommandDialog @@ -47,9 +47,12 @@ self.__process = None - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(False) def startCommand(self, command, args=None): """ @@ -70,7 +73,8 @@ self.__process = QProcess() self.__process.setProcessEnvironment(env) self.__process.setWorkingDirectory(workdir) - self.__process.setProcessChannelMode(QProcess.MergedChannels) + self.__process.setProcessChannelMode( + QProcess.ProcessChannelMode.MergedChannels) self.__process.readyReadStandardOutput.connect(self.__readStdOut) self.__process.finished.connect(self.__processFinished) @@ -84,16 +88,20 @@ self.__process.start(flaskCommand, flaskArgs) ok = self.__process.waitForStarted(10000) if not ok: - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Execute Flask Command"), self.tr("""The Flask process could not be started.""")) else: - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( - Qt.OtherFocusReason) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setFocus( + Qt.FocusReason.OtherFocusReason) else: ok = False @@ -127,14 +135,21 @@ @param exitStatus exit status of the process @type QProcess.ExitStatus """ - self.__normal = (exitStatus == QProcess.NormalExit) and (exitCode == 0) + self.__normal = ( + exitStatus == QProcess.ExitStatus.NormalExit and + exitCode == 0 + ) self.__cancelProcess() - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) - self.buttonBox.button(QDialogButtonBox.Close).setFocus( - Qt.OtherFocusReason) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setFocus( + Qt.FocusReason.OtherFocusReason) if self.__normal and self.__successMessage: self.outputEdit.insertPlainText(self.__successMessage) @@ -148,7 +163,7 @@ """ if ( self.__process is not None and - self.__process.state() != QProcess.NotRunning + self.__process.state() != QProcess.ProcessState.NotRunning ): self.__process.terminate() QTimer.singleShot(2000, self.__process.kill) @@ -164,9 +179,13 @@ @param button reference to the button been clicked @type QAbstractButton """ - if button is self.buttonBox.button(QDialogButtonBox.Close): + if button is self.buttonBox.button( + QDialogButtonBox.StandardButton.Close + ): self.close() - elif button is self.buttonBox.button(QDialogButtonBox.Cancel): + elif button is self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel + ): self.__cancelProcess() def normalExit(self):