ProjectPyramid/PyramidDialog.py

branch
eric7
changeset 147
eb28b4b6f7f5
parent 144
5c3684ee818e
child 148
dcbd3a96f03c
--- a/ProjectPyramid/PyramidDialog.py	Sat May 29 15:05:16 2021 +0200
+++ b/ProjectPyramid/PyramidDialog.py	Tue Jun 01 19:37:46 2021 +0200
@@ -9,10 +9,10 @@
 
 import os
 
-from PyQt5.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication
-from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QLineEdit, QTextEdit
+from PyQt6.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLineEdit, QTextEdit
 
-from E5Gui import E5MessageBox
+from EricWidgets import EricMessageBox
 
 from .Ui_PyramidDialog import Ui_PyramidDialog
 
@@ -34,20 +34,26 @@
         """
         Constructor
         
-        @param text text to be shown by the label (string)
-        @keyparam fixed flag indicating a fixed font should be used (boolean)
-        @keyparam linewrap flag indicating to wrap long lines (boolean)
-        @keyparam msgSuccess optional string to show upon successful execution
-            (string)
-        @keyparam msgError optional string to show upon unsuccessful execution
-            (string)
-        @keyparam parent parent widget (QWidget)
+        @param text text to be shown by the label
+        @type str
+        @param fixed flag indicating a fixed font should be used
+        @type bool
+        @param linewrap flag indicating to wrap long lines
+        @type bool
+        @param msgSuccess optional string to show upon successful execution
+        @type str
+        @param msgError optional string to show upon unsuccessful execution
+        @type str
+        @param parent parent widget
+        @type QWidget
         """
         super().__init__(parent)
         self.setupUi(self)
         
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setEnabled(False)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel).setDefault(True)
         
         self.proc = None
         self.argsLists = []
@@ -66,7 +72,7 @@
                 self.resultbox.setFontFamily("Monospace")
         
         if not linewrap:
-            self.resultbox.setLineWrapMode(QTextEdit.NoWrap)
+            self.resultbox.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap)
         
         self.show()
         QCoreApplication.processEvents()
@@ -78,7 +84,7 @@
         """
         if (
             self.proc is not None and
-            self.proc.state() != QProcess.NotRunning
+            self.proc.state() != QProcess.ProcessState.NotRunning
         ):
             self.proc.terminate()
             QTimer.singleShot(2000, self.proc.kill)
@@ -89,11 +95,15 @@
         
         self.proc = None
         
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
-        self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
-        self.buttonBox.button(QDialogButtonBox.Close).setFocus(
-            Qt.OtherFocusReason)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setEnabled(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setDefault(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setFocus(
+                Qt.FocusReason.OtherFocusReason)
         
         if self.argsLists:
             args = self.argsLists[0][:]
@@ -104,21 +114,31 @@
         """
         Private slot called by a button of the button box clicked.
         
-        @param button button that was clicked (QAbstractButton)
+        @param button button that was clicked
+        @type QAbstractButton
         """
-        if button == self.buttonBox.button(QDialogButtonBox.Close):
+        if button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close
+        ):
             self.close()
-        elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
+        elif button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel
+        ):
             self.finish()
     
     def __procFinished(self, exitCode, exitStatus):
         """
         Private slot connected to the finished signal.
         
-        @param exitCode exit code of the process (integer)
-        @param exitStatus exit status of the process (QProcess.ExitStatus)
+        @param exitCode exit code of the process
+        @type int
+        @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.finish()
         
         if self.normal and self.msgSuccess:
@@ -131,21 +151,30 @@
         """
         Public slot used to start the process.
         
-        @param command command to start (string)
-        @param args list of arguments for the process (list of strings)
-        @keyparam workingDir working directory for the process (string)
-        @keyparam showArgs flag indicating to show the arguments (boolean)
+        @param command command to start
+        @type str
+        @param args list of arguments for the process
+        @type list of str
+        @param workingDir working directory for the process
+        @type str
+        @param showArgs flag indicating to show the arguments
+        @type bool
         @return flag indicating a successful start of the process
+        @rtype bool
         """
         self.errorGroup.hide()
         self.normal = False
         self.intercept = False
         
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setFocus(
-            Qt.OtherFocusReason)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setEnabled(False)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel).setDefault(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel).setFocus(
+                Qt.FocusReason.OtherFocusReason)
         
         if showArgs:
             self.resultbox.append(command + ' ' + ' '.join(args))
@@ -164,7 +193,7 @@
         if not procStarted:
             self.buttonBox.setFocus()
             self.inputGroup.setEnabled(False)
-            E5MessageBox.critical(
+            EricMessageBox.critical(
                 self,
                 self.tr('Process Generation Error'),
                 self.tr(
@@ -181,10 +210,11 @@
         Public slot used to start a batch of processes.
         
         @param argsLists list of lists of arguments for the processes
-            (list of list of string)
-        @param workingDir working directory for the process (string)
+        @type list of list of str
+        @param workingDir working directory for the process
+        @type str
         @return flag indicating a successful start of the first process
-            (boolean)
+        @rtype bool
         """
         self.argsLists = argsLists[:]
         self.workingDir = workingDir
@@ -202,7 +232,8 @@
         """
         Public method to check for a normal process termination.
         
-        @return flag indicating normal process termination (boolean)
+        @return flag indicating normal process termination
+        @rtype bool
         """
         return self.normal
     
@@ -211,7 +242,8 @@
         Public method to check for a normal process termination without
         error messages.
         
-        @return flag indicating normal process termination (boolean)
+        @return flag indicating normal process termination
+        @rtype bool
         """
         return self.normal and self.errors.toPlainText() == ""
     
@@ -252,12 +284,13 @@
         """
         Private slot to handle the password checkbox toggled.
         
-        @param isOn flag indicating the status of the check box (boolean)
+        @param isOn flag indicating the status of the check box
+        @type bool
         """
         if isOn:
-            self.input.setEchoMode(QLineEdit.Password)
+            self.input.setEchoMode(QLineEdit.EchoMode.Password)
         else:
-            self.input.setEchoMode(QLineEdit.Normal)
+            self.input.setEchoMode(QLineEdit.EchoMode.Normal)
     
     @pyqtSlot()
     def on_sendButton_clicked(self):
@@ -290,7 +323,8 @@
         """
         Protected slot to handle a key press event.
         
-        @param evt the key press event (QKeyEvent)
+        @param evt the key press event
+        @type QKeyEvent
         """
         if self.intercept:
             self.intercept = False

eric ide

mercurial