--- a/src/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -20,20 +20,21 @@ class EricMessageBoxWizardDialog(QDialog, Ui_EricMessageBoxWizardDialog): """ Class implementing the eric message box wizard dialog. - + It displays a dialog for entering the parameters for the EricMessageBox code generator. """ + def __init__(self, parent=None): """ Constructor - + @param parent reference to the parent widget @type QWidget """ super().__init__(parent) self.setupUi(self) - + # keep the following three lists in sync self.buttonsList = [ self.tr("No button"), @@ -98,12 +99,13 @@ "EricMessageBox.Yes", "EricMessageBox.YesToAll", ] - + self.defaultCombo.addItems(self.buttonsList) - + self.bTest = self.buttonBox.addButton( - self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole) - + self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole + ) + self.__enabledGroups() def __enabledGroups(self): @@ -111,151 +113,151 @@ Private method to enable/disable some group boxes. """ self.standardButtons.setEnabled( - self.rInformation.isChecked() or - self.rQuestion.isChecked() or - self.rWarning.isChecked() or - self.rCritical.isChecked() or - self.rStandard.isChecked() + self.rInformation.isChecked() + or self.rQuestion.isChecked() + or self.rWarning.isChecked() + or self.rCritical.isChecked() + or self.rStandard.isChecked() ) - + self.defaultButton.setEnabled( - self.rInformation.isChecked() or - self.rQuestion.isChecked() or - self.rWarning.isChecked() or - self.rCritical.isChecked() + self.rInformation.isChecked() + or self.rQuestion.isChecked() + or self.rWarning.isChecked() + or self.rCritical.isChecked() ) - + self.iconBox.setEnabled( - self.rYesNo.isChecked() or - self.rRetryAbort.isChecked() or - self.rStandard.isChecked() + self.rYesNo.isChecked() + or self.rRetryAbort.isChecked() + or self.rStandard.isChecked() ) - + self.bTest.setEnabled(not self.rStandard.isChecked()) - + self.eMessage.setEnabled(not self.rAboutQt.isChecked()) - + @pyqtSlot(bool) def on_rInformation_toggled(self, on): """ Private slot to handle the toggled signal of the rInformation radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rQuestion_toggled(self, on): """ Private slot to handle the toggled signal of the rQuestion radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rWarning_toggled(self, on): """ Private slot to handle the toggled signal of the rWarning radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rCritical_toggled(self, on): """ Private slot to handle the toggled signal of the rCritical radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rYesNo_toggled(self, on): """ Private slot to handle the toggled signal of the rYesNo radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rRetryAbort_toggled(self, on): """ Private slot to handle the toggled signal of the rRetryAbort radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rOkToClearData_toggled(self, on): """ Private slot to handle the toggled signal of the rOkToClearData radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rAbout_toggled(self, on): """ Private slot to handle the toggled signal of the rAbout radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rAboutQt_toggled(self, on): """ Private slot to handle the toggled signal of the rAboutQt radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(bool) def on_rStandard_toggled(self, on): """ Private slot to handle the toggled signal of the rStandard radio button. - + @param on toggle state (ignored) @type bool """ self.__enabledGroups() - + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """ Private slot called by a button of the button box clicked. - + @param button button that was clicked @type QAbstractButton """ if button == self.bTest: self.on_bTest_clicked() - + @pyqtSlot() def on_bTest_clicked(self): """ @@ -263,19 +265,15 @@ """ if self.rAbout.isChecked(): EricMessageBox.about( - None, - self.eCaption.text(), - self.eMessage.toPlainText() + None, self.eCaption.text(), self.eMessage.toPlainText() ) elif self.rAboutQt.isChecked(): - EricMessageBox.aboutQt( - None, self.eCaption.text() - ) + EricMessageBox.aboutQt(None, self.eCaption.text()) elif ( - self.rInformation.isChecked() or - self.rQuestion.isChecked() or - self.rWarning.isChecked() or - self.rCritical.isChecked() + self.rInformation.isChecked() + or self.rQuestion.isChecked() + or self.rWarning.isChecked() + or self.rCritical.isChecked() ): buttons = EricMessageBox.NoButton if self.abortCheck.isChecked(): @@ -316,17 +314,16 @@ buttons |= EricMessageBox.YesToAll if buttons == EricMessageBox.NoButton: buttons = EricMessageBox.Ok - - defaultButton = self.buttonsCodeListBinary[ - self.defaultCombo.currentIndex()] - + + defaultButton = self.buttonsCodeListBinary[self.defaultCombo.currentIndex()] + if self.rInformation.isChecked(): EricMessageBox.information( self, self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) elif self.rQuestion.isChecked(): EricMessageBox.question( @@ -334,7 +331,7 @@ self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) elif self.rWarning.isChecked(): EricMessageBox.warning( @@ -342,7 +339,7 @@ self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) elif self.rCritical.isChecked(): EricMessageBox.critical( @@ -350,12 +347,9 @@ self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) - elif ( - self.rYesNo.isChecked() or - self.rRetryAbort.isChecked() - ): + elif self.rYesNo.isChecked() or self.rRetryAbort.isChecked(): if self.iconInformation.isChecked(): icon = EricMessageBox.Information elif self.iconQuestion.isChecked(): @@ -364,34 +358,28 @@ icon = EricMessageBox.Warning elif self.iconCritical.isChecked(): icon = EricMessageBox.Critical - + if self.rYesNo.isChecked(): EricMessageBox.yesNo( self, self.eCaption.text(), self.eMessage.toPlainText(), icon=icon, - yesDefault=self.yesDefaultCheck.isChecked() + yesDefault=self.yesDefaultCheck.isChecked(), ) elif self.rRetryAbort.isChecked(): EricMessageBox.retryAbort( - self, - self.eCaption.text(), - self.eMessage.toPlainText(), - icon=icon + self, self.eCaption.text(), self.eMessage.toPlainText(), icon=icon ) elif self.rOkToClearData.isChecked(): EricMessageBox.okToClearData( - self, - self.eCaption.text(), - self.eMessage.toPlainText(), - lambda: True + self, self.eCaption.text(), self.eMessage.toPlainText(), lambda: True ) - + def __getStandardButtonCode(self, istring, withIntro=True): """ Private method to generate the button code for the standard buttons. - + @param istring indentation string @type str @param withIntro flag indicating to generate a first line @@ -439,18 +427,19 @@ buttons.append("EricMessageBox.YesToAll") if len(buttons) == 0: return "" - - joinstring = ' |{0}{1}'.format(os.linesep, istring) - intro = ',' if withIntro else '' - btnCode = '{0}{1}{2}{3}'.format( - intro, os.linesep, istring, joinstring.join(buttons)) - + + joinstring = " |{0}{1}".format(os.linesep, istring) + intro = "," if withIntro else "" + btnCode = "{0}{1}{2}{3}".format( + intro, os.linesep, istring, joinstring.join(buttons) + ) + return btnCode - + def __getDefaultButtonCode(self, istring): """ Private method to generate the button code for the default button. - + @param istring indentation string @type str @return the button code @@ -459,15 +448,15 @@ btnCode = "" defaultIndex = self.defaultCombo.currentIndex() if defaultIndex: - btnCode = ',{0}{1}{2}'.format( - os.linesep, istring, - self.buttonsCodeListText[defaultIndex]) + btnCode = ",{0}{1}{2}".format( + os.linesep, istring, self.buttonsCodeListText[defaultIndex] + ) return btnCode - + def getCode(self, indLevel, indString): """ Public method to get the source code. - + @param indLevel indentation level @type int @param indString string used for indentation (space or tab) @@ -479,7 +468,7 @@ il = indLevel + 1 istring = il * indString estring = os.linesep + indLevel * indString - + # now generate the code if self.parentSelf.isChecked(): parent = "self" @@ -489,7 +478,7 @@ parent = self.parentEdit.text() if parent == "": parent = "None" - + if self.iconInformation.isChecked(): icon = "EricMessageBox.Information" elif self.iconQuestion.isChecked(): @@ -498,92 +487,86 @@ icon = "EricMessageBox.Warning" elif self.iconCritical.isChecked(): icon = "EricMessageBox.Critical" - + if not self.rStandard.isChecked(): resvar = self.eResultVar.text() if not resvar: resvar = "res" - + if self.rAbout.isChecked(): msgdlg = "EricMessageBox.about({0}".format(os.linesep) elif self.rAboutQt.isChecked(): msgdlg = "EricMessageBox.aboutQt({0}".format(os.linesep) elif self.rInformation.isChecked(): msgdlg = "{0} = EricMessageBox.information({1}".format( - resvar, os.linesep) + resvar, os.linesep + ) elif self.rQuestion.isChecked(): - msgdlg = "{0} = EricMessageBox.question({1}".format( - resvar, os.linesep) + msgdlg = "{0} = EricMessageBox.question({1}".format(resvar, os.linesep) elif self.rWarning.isChecked(): - msgdlg = "{0} = EricMessageBox.warning({1}".format( - resvar, os.linesep) + msgdlg = "{0} = EricMessageBox.warning({1}".format(resvar, os.linesep) elif self.rCritical.isChecked(): - msgdlg = "{0} = EricMessageBox.critical({1}".format( - resvar, os.linesep) + msgdlg = "{0} = EricMessageBox.critical({1}".format(resvar, os.linesep) elif self.rYesNo.isChecked(): - msgdlg = "{0} = EricMessageBox.yesNo({1}".format( - resvar, os.linesep) + msgdlg = "{0} = EricMessageBox.yesNo({1}".format(resvar, os.linesep) elif self.rRetryAbort.isChecked(): msgdlg = "{0} = EricMessageBox.retryAbort({1}".format( - resvar, os.linesep) + resvar, os.linesep + ) elif self.rOkToClearData.isChecked(): msgdlg = "{0} = EricMessageBox.okToClearData({1}".format( - resvar, os.linesep) - - msgdlg += '{0}{1},{2}'.format(istring, parent, os.linesep) - msgdlg += '{0}self.tr("{1}")'.format( - istring, self.eCaption.text()) - + resvar, os.linesep + ) + + msgdlg += "{0}{1},{2}".format(istring, parent, os.linesep) + msgdlg += '{0}self.tr("{1}")'.format(istring, self.eCaption.text()) + if not self.rAboutQt.isChecked(): msgdlg += ',{0}{1}self.tr("""{2}""")'.format( - os.linesep, istring, self.eMessage.toPlainText()) - + os.linesep, istring, self.eMessage.toPlainText() + ) + if ( - self.rInformation.isChecked() or - self.rQuestion.isChecked() or - self.rWarning.isChecked() or - self.rCritical.isChecked() + self.rInformation.isChecked() + or self.rQuestion.isChecked() + or self.rWarning.isChecked() + or self.rCritical.isChecked() ): msgdlg += self.__getStandardButtonCode(istring) msgdlg += self.__getDefaultButtonCode(istring) elif self.rYesNo.isChecked(): if not self.iconQuestion.isChecked(): - msgdlg += ',{0}{1}icon={2}'.format( - os.linesep, istring, icon) + msgdlg += ",{0}{1}icon={2}".format(os.linesep, istring, icon) if self.yesDefaultCheck.isChecked(): - msgdlg += ',{0}{1}yesDefault=True'.format( - os.linesep, istring) + msgdlg += ",{0}{1}yesDefault=True".format(os.linesep, istring) elif self.rRetryAbort.isChecked(): if not self.iconQuestion.isChecked(): - msgdlg += ',{0}{1}icon={2}'.format( - os.linesep, istring, icon) + msgdlg += ",{0}{1}icon={2}".format(os.linesep, istring, icon) elif self.rOkToClearData.isChecked(): saveFunc = self.saveFuncEdit.text() if saveFunc == "": saveFunc = "lambda: True" - msgdlg += ',{0}{1}{2}'.format(os.linesep, istring, saveFunc) + msgdlg += ",{0}{1}{2}".format(os.linesep, istring, saveFunc) else: resvar = self.eResultVar.text() if not resvar: resvar = "dlg" - + msgdlg = "{0} = EricMessageBox.EricMessageBox({1}".format( - resvar, os.linesep) - msgdlg += '{0}{1},{2}'.format(istring, icon, os.linesep) - msgdlg += '{0}self.tr("{1}")'.format( - istring, self.eCaption.text()) + resvar, os.linesep + ) + msgdlg += "{0}{1},{2}".format(istring, icon, os.linesep) + msgdlg += '{0}self.tr("{1}")'.format(istring, self.eCaption.text()) msgdlg += ',{0}{1}self.tr("""{2}""")'.format( - os.linesep, istring, self.eMessage.toPlainText()) + os.linesep, istring, self.eMessage.toPlainText() + ) if self.modalCheck.isChecked(): - msgdlg += ',{0}{1}modal=True'.format(os.linesep, istring) - btnCode = self.__getStandardButtonCode( - istring, withIntro=False) + msgdlg += ",{0}{1}modal=True".format(os.linesep, istring) + btnCode = self.__getStandardButtonCode(istring, withIntro=False) if btnCode: - msgdlg += ',{0}{1}buttons={2}'.format( - os.linesep, istring, btnCode) + msgdlg += ",{0}{1}buttons={2}".format(os.linesep, istring, btnCode) if not self.parentNone.isChecked(): - msgdlg += ',{0}{1}parent={2}'.format( - os.linesep, istring, parent) - - msgdlg += '{0}){0}'.format(estring) + msgdlg += ",{0}{1}parent={2}".format(os.linesep, istring, parent) + + msgdlg += "{0}){0}".format(estring) return msgdlg