eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py

branch
eric7
changeset 8324
83084f088655
parent 8318
962bce857696
child 8410
f8d97f05f883
--- a/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Tue May 18 19:25:53 2021 +0200
+++ b/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Wed May 19 17:36:34 2021 +0200
@@ -22,6 +22,18 @@
     It displays a dialog for entering the parameters
     for the QFontDialog code generator.
     """
+    FontWeight2Code = {
+        100: "Thin",
+        200: "ExtraLight",
+        300: "Light",
+        400: "Normal",
+        500: "Medium",
+        600: "DemiBold",
+        700: "Bold",
+        800: "ExtraBold",
+        900: "Black",
+    }
+    
     def __init__(self, parent=None):
         """
         Constructor
@@ -117,9 +129,15 @@
                 code += '{0}{1}'.format(os.linesep, istring)
             if not self.eVariable.text():
                 if self.font is not None:
-                    code += 'QFont(["{0}"], {1:d}, {2:d}, {3:d})'.format(
-                        self.font.family(), self.font.pointSize(),
-                        self.font.weight(), self.font.italic())
+                    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:
@@ -130,6 +148,7 @@
             elif parent != "None":
                 code += ',{0}{1}{2}'.format(
                     os.linesep, istring, parent)
+            # NOTE: add support for font dialog options (enhancement)
         code += '){0}'.format(estring)
         
         return code

eric ide

mercurial