--- a/src/eric7/Preferences/SubstyleDefinitionDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Preferences/SubstyleDefinitionDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -19,10 +19,11 @@ """ Class implementing the sub-style definition dialog. """ + def __init__(self, lexer, style, substyle, parent=None): """ Constructor - + @param lexer reference to the lexer object @type PreferencesLexer @param style style number @@ -34,46 +35,51 @@ """ super().__init__(parent) self.setupUi(self) - + self.__lexer = lexer self.__style = style self.__substyle = substyle - - self.header.setText(self.tr("<h3>{0} - {1}</h3>").format( - self.__lexer.language(), self.__lexer.description(self.__style))) + + self.header.setText( + self.tr("<h3>{0} - {1}</h3>").format( + self.__lexer.language(), self.__lexer.description(self.__style) + ) + ) if self.__substyle >= 0: # it's an edit operation self.descriptionEdit.setText( - self.__lexer.description(self.__style, self.__substyle)) + self.__lexer.description(self.__style, self.__substyle) + ) self.wordsEdit.setPlainText( - self.__lexer.words(self.__style, self.__substyle)) - + self.__lexer.words(self.__style, self.__substyle) + ) + def __updateOk(self): """ Private slot to update the state of the OK button. """ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( - bool(self.descriptionEdit.text().strip()) and - bool(self.wordsEdit.toPlainText().strip()) + bool(self.descriptionEdit.text().strip()) + and bool(self.wordsEdit.toPlainText().strip()) ) - + @pyqtSlot(str) def on_descriptionEdit_textChanged(self, txt): """ Private slot handling changes of the description. - + @param txt text of the description @type str """ self.__updateOk() - + @pyqtSlot() def on_wordsEdit_textChanged(self): """ Private slot handling changes of the word list. """ self.__updateOk() - + @pyqtSlot() def on_resetButton_clicked(self): """ @@ -82,49 +88,55 @@ ok = EricMessageBox.yesNo( self, self.tr("Reset Sub-Style Data"), - self.tr("""Shall the entered sub-style data be reset?""")) + self.tr("""Shall the entered sub-style data be reset?"""), + ) if ok: if self.__substyle >= 0: self.descriptionEdit.setText( - self.__lexer.description(self.__style, self.__substyle)) + self.__lexer.description(self.__style, self.__substyle) + ) self.wordsEdit.setPlainText( - self.__lexer.words(self.__style, self.__substyle)) + self.__lexer.words(self.__style, self.__substyle) + ) else: self.descriptionEdit.clear() self.wordsEdit.clear() - + @pyqtSlot() def on_defaultButton_clicked(self): """ Private slot to set the dialog contents to default values. """ - filled = ( - bool(self.descriptionEdit.text().strip()) or - bool(self.wordsEdit.toPlainText().strip()) + filled = bool(self.descriptionEdit.text().strip()) or bool( + self.wordsEdit.toPlainText().strip() ) ok = ( EricMessageBox.yesNo( self, self.tr("Set Sub-Style Data to Default"), - self.tr("""Shall the sub-style data be set to default""" - """ values?""")) - if filled else - True + self.tr( + """Shall the sub-style data be set to default""" """ values?""" + ), + ) + if filled + else True ) if ok: if self.__substyle >= 0: - self.descriptionEdit.setText(self.__lexer.defaultDescription( - self.__style, self.__substyle)) - self.wordsEdit.setPlainText(self.__lexer.defaultWords( - self.__style, self.__substyle)) + self.descriptionEdit.setText( + self.__lexer.defaultDescription(self.__style, self.__substyle) + ) + self.wordsEdit.setPlainText( + self.__lexer.defaultWords(self.__style, self.__substyle) + ) else: self.descriptionEdit.clear() self.wordsEdit.clear() - + def getData(self): """ Public method to get the entered data. - + @return tuple containing the sub-style description and words list. @rtype tuple of (str, str) """