ProjectFlask/FlaskBabelExtension/PyBabelCommandDialog.py

branch
eric7
changeset 64
0ee58185b8df
parent 61
fe1e8783a95f
child 66
0d3168d0e310
diff -r 7c05cbc8b3e5 -r 0ee58185b8df ProjectFlask/FlaskBabelExtension/PyBabelCommandDialog.py
--- a/ProjectFlask/FlaskBabelExtension/PyBabelCommandDialog.py	Sat May 29 15:04:41 2021 +0200
+++ b/ProjectFlask/FlaskBabelExtension/PyBabelCommandDialog.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
 
@@ -49,9 +49,12 @@
         self.__argsLists = []
         self.__workdir = ""
         
-        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, workdir, clearOutput=True):
         """
@@ -72,7 +75,8 @@
         
         self.__process = QProcess()
         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)
@@ -87,16 +91,20 @@
         self.__process.start(babelCommand, babelArgs)
         ok = self.__process.waitForStarted(10000)
         if not ok:
-            E5MessageBox.critical(
+            EricMessageBox.critical(
                 None,
                 self.tr("Execute PyBabel Command"),
                 self.tr("""The pybabel 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)
         
         return ok
     
@@ -152,7 +160,10 @@
         @param exitStatus exit status of the process
         @type QProcess.ExitStatus
         """
-        normal = (exitStatus == QProcess.NormalExit) and (exitCode == 0)
+        normal = (
+            exitStatus == QProcess.ExitStatus.NormalExit and
+            exitCode == 0
+        )
         self.__cancelProcess()
         
         if self.__argsLists:
@@ -161,11 +172,14 @@
                               clearOutput=False)
             return
         
-        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 normal and self.__successMessage:
             self.outputEdit.insertPlainText(self.__successMessage)
@@ -179,7 +193,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)
@@ -195,8 +209,12 @@
         @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.__argsLists = []
             self.__cancelProcess()

eric ide

mercurial