src/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9433
6df1aeaa4529
--- a/src/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -18,10 +18,11 @@
 class FontDialogWizardDialog(QDialog, Ui_FontDialogWizardDialog):
     """
     Class implementing the font dialog wizard dialog.
-    
+
     It displays a dialog for entering the parameters
     for the QFontDialog code generator.
     """
+
     FontWeight2Code = {
         100: "Thin",
         200: "ExtraLight",
@@ -33,19 +34,20 @@
         800: "ExtraBold",
         900: "Black",
     }
-    
+
     def __init__(self, parent=None):
         """
         Constructor
-        
+
         @param parent parent widget (QWidget)
         """
         super().__init__(parent)
         self.setupUi(self)
-        
+
         self.bTest = self.buttonBox.addButton(
-            self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole)
-        
+            self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole
+        )
+
         self.font = None
         self.fontOptions = {
             "noNativeDialog": False,
@@ -54,19 +56,19 @@
             "monospacedFonts": False,
             "proportionalFonts": False,
         }
-        
+
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
-        
+
     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):
         """
@@ -87,24 +89,19 @@
                     options |= QFontDialog.FontDialogOption.MonospacedFonts
                 if self.fontOptions["proportionalFonts"]:
                     options |= QFontDialog.FontDialogOption.ProportionalFonts
-            QFontDialog.getFont(
-                self.font,
-                self,
-                self.eCaption.text(),
-                options
-            )
-    
+            QFontDialog.getFont(self.font, self, self.eCaption.text(), options)
+
     def on_eVariable_textChanged(self, text):
         """
         Private slot to handle the textChanged signal of eVariable.
-        
+
         @param text the new text (string)
         """
         if not text:
             self.bTest.setEnabled(True)
         else:
             self.bTest.setEnabled(False)
-        
+
     @pyqtSlot()
     def on_fontButton_clicked(self):
         """
@@ -119,21 +116,22 @@
             self.font = font
         else:
             self.font = None
-    
+
     @pyqtSlot()
     def on_optionsButton_clicked(self):
         """
         Private slot to handle the selection of font dialog options.
         """
         from .FontDialogOptionsDialog import FontDialogOptionsDialog
+
         dlg = FontDialogOptionsDialog(self.fontOptions, self)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             self.fontOptions = dlg.getOptions()
-    
+
     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)
@@ -142,7 +140,7 @@
         il = indLevel + 1
         istring = il * indString
         estring = os.linesep + indLevel * indString
-        
+
         # generate the code
         resvar = self.eResultVar.text()
         if not resvar:
@@ -156,54 +154,40 @@
             parent = self.parentEdit.text()
             if parent == "":
                 parent = "None"
-        
-        code = '{0}, ok = QFontDialog.getFont('.format(resvar)
+
+        code = "{0}, ok = QFontDialog.getFont(".format(resvar)
         if self.eVariable.text() or self.font is not None:
             if title or parent != "None":
-                code += '{0}{1}'.format(os.linesep, istring)
+                code += "{0}{1}".format(os.linesep, istring)
             if not self.eVariable.text():
                 if self.font is not None:
-                    code += (
-                        'QFont(["{0}"], {1:d}, QFont.Weight.{2}, {3})'
-                        .format(
-                            self.font.family(),
-                            self.font.pointSize(),
-                            FontDialogWizardDialog.FontWeight2Code[
-                                self.font.weight()],
-                            "True" if self.font.italic() else "False")
+                    code += 'QFont(["{0}"], {1:d}, QFont.Weight.{2}, {3})'.format(
+                        self.font.family(),
+                        self.font.pointSize(),
+                        FontDialogWizardDialog.FontWeight2Code[self.font.weight()],
+                        "True" if self.font.italic() else "False",
                     )
             else:
                 code += self.eVariable.text()
             if title:
-                code += ',{0}{1}{2}'.format(
-                    os.linesep, istring, parent)
-                code += ',{0}{1}self.tr("{2}")'.format(
-                    os.linesep, istring, title)
+                code += ",{0}{1}{2}".format(os.linesep, istring, parent)
+                code += ',{0}{1}self.tr("{2}")'.format(os.linesep, istring, title)
             elif parent != "None":
-                code += ',{0}{1}{2}'.format(
-                    os.linesep, istring, parent)
+                code += ",{0}{1}{2}".format(os.linesep, istring, parent)
             if any(self.fontOptions.values()):
                 options = []
                 if self.fontOptions["noNativeDialog"]:
-                    options.append(
-                        "QFontDialog.FontDialogOption.DontUseNativeDialog")
+                    options.append("QFontDialog.FontDialogOption.DontUseNativeDialog")
                 if self.fontOptions["scalableFonts"]:
-                    options.append(
-                        "QFontDialog.FontDialogOption.ScalableFonts")
+                    options.append("QFontDialog.FontDialogOption.ScalableFonts")
                 if self.fontOptions["nonScalableFonts"]:
-                    options.append(
-                        "QFontDialog.FontDialogOption.NonScalableFonts")
+                    options.append("QFontDialog.FontDialogOption.NonScalableFonts")
                 if self.fontOptions["monospacedFonts"]:
-                    options.append(
-                        "QFontDialog.FontDialogOption.MonospacedFonts")
+                    options.append("QFontDialog.FontDialogOption.MonospacedFonts")
                 if self.fontOptions["proportionalFonts"]:
-                    options.append(
-                        "QFontDialog.FontDialogOption.ProportionalFonts")
-                fontOptionsString = (
-                    ' |{0}{1}'.format(os.linesep, istring).join(options)
-                )
-                code += ',{0}{1}{2}'.format(
-                    os.linesep, istring, fontOptionsString)
-        code += '{0}){0}'.format(estring)
-        
+                    options.append("QFontDialog.FontDialogOption.ProportionalFonts")
+                fontOptionsString = " |{0}{1}".format(os.linesep, istring).join(options)
+                code += ",{0}{1}{2}".format(os.linesep, istring, fontOptionsString)
+        code += "{0}){0}".format(estring)
+
         return code

eric ide

mercurial