Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py

branch
Py2 comp.
changeset 3142
55030c09e142
parent 3056
9986ec0e559a
parent 3125
385a62b53725
child 3145
a9de05d4a22f
equal deleted inserted replaced
3141:72f3bde98c58 3142:55030c09e142
89 89
90 @param indLevel indentation level (int) 90 @param indLevel indentation level (int)
91 @param indString string used for indentation (space or tab) (string) 91 @param indString string used for indentation (space or tab) (string)
92 @return generated code (string) 92 @return generated code (string)
93 """ 93 """
94 # calculate our indentation level and the indentation string
95 il = indLevel + 1
96 istring = il * indString
94 estring = os.linesep + indLevel * indString 97 estring = os.linesep + indLevel * indString
95 98
96 # generate the code 99 # generate the code
97 code = 'QFontDialog.getFont(' 100 resvar = self.eResultVar.text()
98 if not self.eVariable.text(): 101 if not resvar:
99 if self.font is not None: 102 resvar = "font"
100 code += 'QFont("{0}", {1:d}, {2:d}, {3:d})'.format( 103 title = self.eCaption.text()
101 self.font.family(), self.font.pointSize(), 104 if self.parentSelf.isChecked():
102 self.font.weight(), self.font.italic()) 105 parent = "self"
103 else: 106 elif self.parentNone.isChecked():
104 code += self.eVariable.text() 107 parent = "None"
108 elif self.parentOther.isChecked():
109 parent = self.parentEdit.text()
110 if parent == "":
111 parent = "None"
112
113 code = '{0}, ok = QFontDialog.getFont('.format(resvar)
114 if self.eVariable.text() or self.font is not None:
115 if title or parent != "None":
116 code += '{0}{1}'.format(os.linesep, istring)
117 if not self.eVariable.text():
118 if self.font is not None:
119 code += 'QFont("{0}", {1:d}, {2:d}, {3:d})'.format(
120 self.font.family(), self.font.pointSize(),
121 self.font.weight(), self.font.italic())
122 else:
123 code += self.eVariable.text()
124 if title:
125 code += ',{0}{1}{2}'.format(
126 os.linesep, istring, parent)
127 code += ',{0}{1}self.trUtf8("{2}")'.format(
128 os.linesep, istring, title)
129 elif parent != "None":
130 code += ',{0}{1}{2}'.format(
131 os.linesep, istring, parent)
105 code += '){0}'.format(estring) 132 code += '){0}'.format(estring)
106 133
107 return code 134 return code

eric ide

mercurial