--- a/src/eric7/Plugins/PluginWizardQMessageBox.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/PluginWizardQMessageBox.py Wed Jul 13 14:55:47 2022 +0200 @@ -36,10 +36,11 @@ """ Class implementing the QMessageBox wizard plugin. """ + def __init__(self, ui): """ Constructor - + @param ui reference to the user interface object (UI.UserInterface) """ super().__init__(ui) @@ -48,12 +49,12 @@ def activate(self): """ Public method to activate this plugin. - + @return tuple of None and activation status (boolean) """ self.__initAction() self.__initMenu() - + return None, True def deactivate(self): @@ -63,26 +64,32 @@ menu = self.__ui.getMenu("wizards") if menu: menu.removeAction(self.action) - self.__ui.removeEricActions([self.action], 'wizards') - + self.__ui.removeEricActions([self.action], "wizards") + def __initAction(self): """ Private method to initialize the action. """ self.action = EricAction( - self.tr('QMessageBox Wizard'), - self.tr('QMessageBox Wizard...'), 0, 0, self, - 'wizards_qmessagebox') - self.action.setStatusTip(self.tr('QMessageBox Wizard')) - self.action.setWhatsThis(self.tr( - """<b>QMessageBox Wizard</b>""" - """<p>This wizard opens a dialog for entering all the parameters""" - """ needed to create a QMessageBox. The generated code is""" - """ inserted at the current cursor position.</p>""" - )) + self.tr("QMessageBox Wizard"), + self.tr("QMessageBox Wizard..."), + 0, + 0, + self, + "wizards_qmessagebox", + ) + self.action.setStatusTip(self.tr("QMessageBox Wizard")) + self.action.setWhatsThis( + self.tr( + """<b>QMessageBox Wizard</b>""" + """<p>This wizard opens a dialog for entering all the parameters""" + """ needed to create a QMessageBox. The generated code is""" + """ inserted at the current cursor position.</p>""" + ) + ) self.action.triggered.connect(self.__handle) - - self.__ui.addEricActions([self.action], 'wizards') + + self.__ui.addEricActions([self.action], "wizards") def __initMenu(self): """ @@ -91,40 +98,42 @@ menu = self.__ui.getMenu("wizards") if menu: menu.addAction(self.action) - + def __callForm(self, editor): """ Private method to display a dialog and get the code. - + @param editor reference to the current editor @return the generated code (string) """ from WizardPlugins.MessageBoxWizard.MessageBoxWizardDialog import ( - MessageBoxWizardDialog + MessageBoxWizardDialog, ) + dlg = MessageBoxWizardDialog(None) if dlg.exec() == QDialog.DialogCode.Accepted: line, index = editor.getCursorPosition() indLevel = editor.indentation(line) // editor.indentationWidth() if editor.indentationsUseTabs(): - indString = '\t' + indString = "\t" else: - indString = editor.indentationWidth() * ' ' + indString = editor.indentationWidth() * " " return (dlg.getCode(indLevel, indString), True) else: return (None, False) - + def __handle(self): """ Private method to handle the wizards action. """ editor = ericApp().getObject("ViewManager").activeWindow() - + if editor is None: EricMessageBox.critical( self.__ui, - self.tr('No current editor'), - self.tr('Please open or create a file first.')) + self.tr("No current editor"), + self.tr("Please open or create a file first."), + ) else: code, ok = self.__callForm(editor) if ok: