eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py

branch
eric7
changeset 8324
83084f088655
parent 8318
962bce857696
child 8410
f8d97f05f883
equal deleted inserted replaced
8323:3bb9b7d997db 8324:83084f088655
20 Class implementing the font dialog wizard dialog. 20 Class implementing the font dialog wizard dialog.
21 21
22 It displays a dialog for entering the parameters 22 It displays a dialog for entering the parameters
23 for the QFontDialog code generator. 23 for the QFontDialog code generator.
24 """ 24 """
25 FontWeight2Code = {
26 100: "Thin",
27 200: "ExtraLight",
28 300: "Light",
29 400: "Normal",
30 500: "Medium",
31 600: "DemiBold",
32 700: "Bold",
33 800: "ExtraBold",
34 900: "Black",
35 }
36
25 def __init__(self, parent=None): 37 def __init__(self, parent=None):
26 """ 38 """
27 Constructor 39 Constructor
28 40
29 @param parent parent widget (QWidget) 41 @param parent parent widget (QWidget)
115 if self.eVariable.text() or self.font is not None: 127 if self.eVariable.text() or self.font is not None:
116 if title or parent != "None": 128 if title or parent != "None":
117 code += '{0}{1}'.format(os.linesep, istring) 129 code += '{0}{1}'.format(os.linesep, istring)
118 if not self.eVariable.text(): 130 if not self.eVariable.text():
119 if self.font is not None: 131 if self.font is not None:
120 code += 'QFont(["{0}"], {1:d}, {2:d}, {3:d})'.format( 132 code += (
121 self.font.family(), self.font.pointSize(), 133 'QFont(["{0}"], {1:d}, QFont.Weight.{2}, {3})'
122 self.font.weight(), self.font.italic()) 134 .format(
135 self.font.family(),
136 self.font.pointSize(),
137 FontDialogWizardDialog.FontWeight2Code[
138 self.font.weight()],
139 "True" if self.font.italic() else "False")
140 )
123 else: 141 else:
124 code += self.eVariable.text() 142 code += self.eVariable.text()
125 if title: 143 if title:
126 code += ',{0}{1}{2}'.format( 144 code += ',{0}{1}{2}'.format(
127 os.linesep, istring, parent) 145 os.linesep, istring, parent)
128 code += ',{0}{1}self.tr("{2}")'.format( 146 code += ',{0}{1}self.tr("{2}")'.format(
129 os.linesep, istring, title) 147 os.linesep, istring, title)
130 elif parent != "None": 148 elif parent != "None":
131 code += ',{0}{1}{2}'.format( 149 code += ',{0}{1}{2}'.format(
132 os.linesep, istring, parent) 150 os.linesep, istring, parent)
151 # NOTE: add support for font dialog options (enhancement)
133 code += '){0}'.format(estring) 152 code += '){0}'.format(estring)
134 153
135 return code 154 return code

eric ide

mercurial