--- a/src/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -18,19 +18,20 @@ class MessageBoxWizardDialog(QDialog, Ui_MessageBoxWizardDialog): """ Class implementing the message box wizard dialog. - + It displays a dialog for entering the parameters for the QMessageBox code generator. """ + def __init__(self, parent=None): """ Constructor - + @param parent parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) - + # keep the following three lists in sync self.buttonsList = [ self.tr("No button"), @@ -95,12 +96,13 @@ "QMessageBox.StandardButton.Yes", "QMessageBox.StandardButton.YesToAll", ] - + self.defaultCombo.addItems(self.buttonsList) - + self.bTest = self.buttonBox.addButton( - self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole) - + self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole + ) + def __testSelectedOptions(self): """ Private method to test the selected options. @@ -144,17 +146,16 @@ buttons |= QMessageBox.StandardButton.YesToAll if buttons == QMessageBox.StandardButton.NoButton: buttons = QMessageBox.StandardButton.Ok - - defaultButton = self.buttonsCodeListBinary[ - self.defaultCombo.currentIndex()] - + + defaultButton = self.buttonsCodeListBinary[self.defaultCombo.currentIndex()] + if self.rInformation.isChecked(): QMessageBox.information( self, self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) elif self.rQuestion.isChecked(): QMessageBox.question( @@ -162,7 +163,7 @@ self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) elif self.rWarning.isChecked(): QMessageBox.warning( @@ -170,7 +171,7 @@ self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) elif self.rCritical.isChecked(): QMessageBox.critical( @@ -178,37 +179,30 @@ self.eCaption.text(), self.eMessage.toPlainText(), buttons, - defaultButton + defaultButton, ) - + def on_buttonBox_clicked(self, button): """ Private slot called by a button of the button box clicked. - + @param button button that was clicked (QAbstractButton) """ if button == self.bTest: self.on_bTest_clicked() - + @pyqtSlot() def on_bTest_clicked(self): """ Private method to test the selected options. """ if self.rAbout.isChecked(): - QMessageBox.about( - None, - self.eCaption.text(), - self.eMessage.toPlainText() - ) + QMessageBox.about(None, self.eCaption.text(), self.eMessage.toPlainText()) elif self.rAboutQt.isChecked(): - QMessageBox.aboutQt( - None, - self.eCaption.text() - ) + QMessageBox.aboutQt(None, self.eCaption.text()) else: self.__testSelectedOptions() - + def __enabledGroups(self): """ Private method to enable/disable some group boxes. @@ -217,29 +211,29 @@ self.standardButtons.setEnabled(enable) self.lResultVar.setEnabled(enable) self.eResultVar.setEnabled(enable) - + self.eMessage.setEnabled(not self.rAboutQt.isChecked()) - + def on_rAbout_toggled(self, on): """ Private slot to handle the toggled signal of the rAbout radio button. - + @param on toggle state (boolean) (ignored) """ self.__enabledGroups() - + def on_rAboutQt_toggled(self, on): """ Private slot to handle the toggled signal of the rAboutQt radio button. - + @param on toggle state (boolean) (ignored) """ self.__enabledGroups() - + def __getButtonCode(self, istring, indString): """ Private method to generate the button code. - + @param istring indentation string (string) @param indString string used for indentation (space or tab) (string) @return the button code (string) @@ -283,24 +277,22 @@ buttons.append("QMessageBox.StandardButton.YesToAll") if len(buttons) == 0: return "" - + istring2 = istring + indString - joinstring = ' |{0}{1}'.format(os.linesep, istring2) - btnCode = ',{0}{1}('.format( - os.linesep, istring) - btnCode += '{0}{1}{2})'.format( - os.linesep, istring2, joinstring.join(buttons)) + joinstring = " |{0}{1}".format(os.linesep, istring2) + btnCode = ",{0}{1}(".format(os.linesep, istring) + btnCode += "{0}{1}{2})".format(os.linesep, istring2, joinstring.join(buttons)) 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 (int) @param indString string used for indentation (space or tab) (string) @return generated code (string) @@ -309,7 +301,7 @@ il = indLevel + 1 istring = il * indString estring = os.linesep + indLevel * indString - + # now generate the code if self.parentSelf.isChecked(): parent = "self" @@ -319,11 +311,11 @@ parent = self.parentEdit.text() if parent == "": parent = "None" - + resvar = self.eResultVar.text() if not resvar: resvar = "res" - + if self.rAbout.isChecked(): msgdlg = "QMessageBox.about(" elif self.rAboutQt.isChecked(): @@ -336,21 +328,24 @@ msgdlg = "{0} = QMessageBox.warning(".format(resvar) else: msgdlg = "{0} = QMessageBox.critical(".format(resvar) - + if self.rAboutQt.isChecked(): if self.eCaption.text(): - msgdlg += '{0}{1}{2}'.format(os.linesep, istring, parent) + msgdlg += "{0}{1}{2}".format(os.linesep, istring, parent) msgdlg += ',{0}{1}self.tr("{2}")'.format( - os.linesep, istring, self.eCaption.text()) + os.linesep, istring, self.eCaption.text() + ) else: msgdlg += parent else: - msgdlg += '{0}{1}{2}'.format(os.linesep, istring, parent) + msgdlg += "{0}{1}{2}".format(os.linesep, istring, parent) msgdlg += ',{0}{1}self.tr("{2}")'.format( - os.linesep, istring, self.eCaption.text()) + os.linesep, istring, self.eCaption.text() + ) msgdlg += ',{0}{1}self.tr("""{2}""")'.format( - os.linesep, istring, self.eMessage.toPlainText()) + os.linesep, istring, self.eMessage.toPlainText() + ) if not self.rAbout.isChecked() and not self.rAboutQt.isChecked(): msgdlg += self.__getButtonCode(istring, indString) - msgdlg += '{0}){0}'.format(estring) + msgdlg += "{0}){0}".format(estring) return msgdlg