Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py

branch
Py2 comp.
changeset 3142
55030c09e142
parent 3060
5883ce99ee12
parent 3125
385a62b53725
child 3145
a9de05d4a22f
diff -r 72f3bde98c58 -r 55030c09e142 Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py
--- a/Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py	Fri Dec 13 22:45:47 2013 +0100
+++ b/Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py	Fri Dec 13 23:39:14 2013 +0100
@@ -124,30 +124,47 @@
         estring = os.linesep + indLevel * indString
         
         # now generate the code
-        code = 'QColorDialog.'
+        if self.parentSelf.isChecked():
+            parent = "self"
+        elif self.parentNone.isChecked():
+            parent = "None"
+        elif self.parentOther.isChecked():
+            parent = self.parentEdit.text()
+            if parent == "":
+                parent = "None"
+        
+        resvar = self.eResultVar.text()
+        if not resvar:
+            resvar = "color"
+        code = '{0} = QColorDialog.'.format(resvar)
         if self.rColor.isChecked():
-            code += 'getColor('
+            code += 'getColor({0}'.format(os.linesep)
             if self.eColor.currentText():
                 col = self.eColor.currentText()
                 if col.startswith('#'):
-                    code += 'QColor("{0}")'.format(col)
+                    code += '{0}QColor("{1}"),{2}'.format(
+                        istring, col, os.linesep)
                 else:
-                    code += 'QColor({0})'.format(col)
-            code += ', None,{0}'.format(os.linesep)
+                    code += '{0}QColor({1}),{2}'.format(
+                        istring, col, os.linesep)
+            else:
+                code += '{0}QColor(Qt.white),{1}'.format(istring, os.linesep)
+            code += '{0}{1},{2}'.format(istring, parent, os.linesep)
             code += '{0}self.trUtf8("{1}"),{2}'.format(
                 istring, self.eTitle.text(), os.linesep)
             code += '{0}QColorDialog.ColorDialogOptions(' \
                 'QColorDialog.ShowAlphaChannel)'.format(istring)
             code += '){0}'.format(estring)
         elif self.rRGBA.isChecked():
-            code += 'getColor('
+            code += 'getColor({0}'.format(os.linesep)
             if not self.eRGB.text():
-                code += 'QColor({0:d}, {1:d}, {2:d}, {3:d}),{4}'.format(
-                    self.sRed.value(), self.sGreen.value(), self.sBlue.value(),
-                    self.sAlpha.value(), os.linesep)
+                code += '{0}QColor({1:d}, {2:d}, {3:d}, {4:d}),{5}'.format(
+                    istring, self.sRed.value(), self.sGreen.value(),
+                    self.sBlue.value(), self.sAlpha.value(), os.linesep)
             else:
-                code += '{0},{1}'.format(self.eRGB.text(), os.linesep)
-            code += '{0}None,{1}'.format(istring, os.linesep)
+                code += '{0}{1},{2}'.format(
+                    istring, self.eRGB.text(), os.linesep)
+            code += '{0}{1},{2}'.format(istring, parent, os.linesep)
             code += '{0}self.trUtf8("{1}"),{2}'.format(
                 istring, self.eTitle.text(), os.linesep)
             code += '{0}QColorDialog.ColorDialogOptions(' \

eric ide

mercurial