eric6/Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2003 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the color dialog wizard dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtCore import pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtGui import QColor
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
14 from PyQt5.QtWidgets import QColorDialog, QDialog, QDialogButtonBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
16 from E5Gui import E5MessageBox
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
17
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
18 from .Ui_ColorDialogWizardDialog import Ui_ColorDialogWizardDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class ColorDialogWizardDialog(QDialog, Ui_ColorDialogWizardDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing the color dialog wizard dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 It displays a dialog for entering the parameters
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 for the QColorDialog code generator.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, parent=None):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
34 super(ColorDialogWizardDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
3005
3953ddfb991d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
37 self.bTest = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
38 self.tr("Test"), QDialogButtonBox.ActionRole)
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
39
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
40 msh = self.minimumSizeHint()
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
41 self.resize(max(self.width(), msh.width()), msh.height())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Private slot called by a button of the button box clicked.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 if button == self.bTest:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.on_bTest_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 def on_bTest_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Private method to test the selected options.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 if self.rColor.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 if not self.eColor.currentText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 QColorDialog.getColor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 coStr = self.eColor.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 if coStr.startswith('#'):
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
63 coStr = "QColor('{0}')".format(coStr)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 else:
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
65 coStr = "QColor({0})".format(coStr)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 try:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7537
diff changeset
67 exec('from PyQt5.QtCore import Qt;' # secok
2128
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
68 ' QColorDialog.getColor({0}, None, "{1}")'.format(
3037
a417a0670a36 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
69 coStr, self.eTitle.text()))
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
70 except Exception:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3005
diff changeset
71 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3005
diff changeset
72 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
73 self.tr("QColorDialog Wizard Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
74 self.tr(
7537
4e2d6b12f67c Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
75 """<p>The color <b>{0}</b> is not valid.</p>""")
3037
a417a0670a36 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
76 .format(coStr))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 elif self.rRGBA.isChecked():
2128
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
79 QColorDialog.getColor(
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
80 QColor(self.sRed.value(), self.sGreen.value(),
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
81 self.sBlue.value(), self.sAlpha.value()),
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
82 None, self.eTitle.text(),
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
83 QColorDialog.ColorDialogOptions(QColorDialog.ShowAlphaChannel))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 def on_eRGB_textChanged(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 Private slot to handle the textChanged signal of eRGB.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @param text the new text (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 if not text:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.sRed.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.sGreen.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.sBlue.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.sAlpha.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.bTest.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.sRed.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.sGreen.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.sBlue.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.sAlpha.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.bTest.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def on_eColor_editTextChanged(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Private slot to handle the editTextChanged signal of eColor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @param text the new text (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 if not text or text.startswith('Qt.') or text.startswith('#'):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.bTest.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.bTest.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 def getCode(self, indLevel, indString):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 Public method to get the source code.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @param indLevel indentation level (int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 @param indString string used for indentation (space or tab) (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @return generated code (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 # calculate our indentation level and the indentation string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 il = indLevel + 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 istring = il * indString
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
126 estring = os.linesep + indLevel * indString
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 # now generate the code
3125
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
129 if self.parentSelf.isChecked():
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
130 parent = "self"
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
131 elif self.parentNone.isChecked():
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
132 parent = "None"
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
133 elif self.parentOther.isChecked():
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
134 parent = self.parentEdit.text()
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
135 if parent == "":
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
136 parent = "None"
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
137
3124
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3118
diff changeset
138 resvar = self.eResultVar.text()
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3118
diff changeset
139 if not resvar:
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3118
diff changeset
140 resvar = "color"
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3118
diff changeset
141 code = '{0} = QColorDialog.'.format(resvar)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if self.rColor.isChecked():
3118
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
143 code += 'getColor({0}'.format(os.linesep)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if self.eColor.currentText():
42
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
145 col = self.eColor.currentText()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 if col.startswith('#'):
3118
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
147 code += '{0}QColor("{1}"),{2}'.format(
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
148 istring, col, os.linesep)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 else:
3118
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
150 code += '{0}QColor({1}),{2}'.format(
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
151 istring, col, os.linesep)
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
152 else:
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
153 code += '{0}QColor(Qt.white),{1}'.format(istring, os.linesep)
3125
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
154 code += '{0}{1},{2}'.format(istring, parent, os.linesep)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
155 code += '{0}self.tr("{1}"),{2}'.format(
2128
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
156 istring, self.eTitle.text(), os.linesep)
7258
aff39db4dacc Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
157 code += (
aff39db4dacc Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
158 '{0}QColorDialog.ColorDialogOptions('
3005
3953ddfb991d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
159 'QColorDialog.ShowAlphaChannel)'.format(istring)
7258
aff39db4dacc Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
160 )
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
161 code += '){0}'.format(estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 elif self.rRGBA.isChecked():
3118
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
163 code += 'getColor({0}'.format(os.linesep)
2128
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
164 if not self.eRGB.text():
3118
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
165 code += '{0}QColor({1:d}, {2:d}, {3:d}, {4:d}),{5}'.format(
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
166 istring, self.sRed.value(), self.sGreen.value(),
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
167 self.sBlue.value(), self.sAlpha.value(), os.linesep)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 else:
3118
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
169 code += '{0}{1},{2}'.format(
b1278ba1d7fe Changed the QColorDialog wizard to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3037
diff changeset
170 istring, self.eRGB.text(), os.linesep)
3125
385a62b53725 Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3124
diff changeset
171 code += '{0}{1},{2}'.format(istring, parent, os.linesep)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
172 code += '{0}self.tr("{1}"),{2}'.format(
2128
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
173 istring, self.eTitle.text(), os.linesep)
7258
aff39db4dacc Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
174 code += (
aff39db4dacc Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
175 '{0}QColorDialog.ColorDialogOptions('
3005
3953ddfb991d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
176 'QColorDialog.ShowAlphaChannel)'.format(istring)
7258
aff39db4dacc Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
177 )
2128
bf80601e12d3 Removed obsolete functionality from Color Dialog Wizard and corrected an issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
178 code += '){0}'.format(estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
180 return code

eric ide

mercurial