Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py

Thu, 13 Mar 2014 19:21:25 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 13 Mar 2014 19:21:25 +0100
changeset 3366
6084bb3c3911
parent 3190
a9a94491c4fd
child 3484
645c12de6b0c
permissions
-rw-r--r--

Made some changes to have a bunch of dialogs with correct sizes.

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
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3154
diff changeset
3 # Copyright (c) 2003 - 2014 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 input 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
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
12 from PyQt4.QtCore import pyqtSlot
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
13 from PyQt4.QtGui import QLineEdit, QDoubleValidator, QDialog, QInputDialog, \
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
14 QDialogButtonBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
16 from .Ui_InputDialogWizardDialog import Ui_InputDialogWizardDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
18
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class InputDialogWizardDialog(QDialog, Ui_InputDialogWizardDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing the input dialog wizard dialog.
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 It displays a dialog for entering the parameters
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 for the QInputDialog code generator.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 def __init__(self, parent=None):
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 Constructor
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 @param parent parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
32 super().__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 # set the validators for the double line edots
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
36 self.eDoubleDefault.setValidator(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 QDoubleValidator(-2147483647, 2147483647, 99, self.eDoubleDefault))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
38 self.eDoubleFrom.setValidator(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 QDoubleValidator(-2147483647, 2147483647, 99, self.eDoubleFrom))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
40 self.eDoubleTo.setValidator(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 QDoubleValidator(-2147483647, 2147483647, 99, self.eDoubleTo))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
43 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
44 self.tr("Test"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
46 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
47 self.resize(max(self.width(), msh.width()), msh.height())
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
48
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 @pyqtSlot(bool)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 def on_rItem_toggled(self, checked):
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 Private slot to perform actions dependant on the item type selection.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @param checked flag indicating the checked state (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.bTest.setEnabled(not checked)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 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
61
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 if button == self.bTest:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.on_bTest_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 def on_bTest_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 Private method to test the selected options.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 if self.rText.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 if self.rEchoNormal.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 echomode = QLineEdit.Normal
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 elif self.rEchoNoEcho.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 echomode = QLineEdit.NoEcho
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 echomode = QLineEdit.Password
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
79 QInputDialog.getText(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 None,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.eCaption.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.eLabel.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 echomode,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.eTextDefault.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 elif self.rInteger.isChecked():
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
86 QInputDialog.getInt(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 None,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.eCaption.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.eLabel.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.sIntDefault.value(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.sIntFrom.value(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.sIntTo.value(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.sIntStep.value())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 elif self.rDouble.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 doubleDefault = float(self.eDoubleDefault.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 doubleDefault = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 doubleFrom = float(self.eDoubleFrom.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 doubleFrom = -2147483647
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 doubleTo = float(self.eDoubleTo.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 doubleTo = 2147483647
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
107 QInputDialog.getDouble(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 None,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.eCaption.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.eLabel.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 doubleDefault,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 doubleFrom,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 doubleTo,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.sDoubleDecimals.value())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
3119
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2893
diff changeset
116 def getCode(self, indLevel, indString):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
2297
e8a46f81517c Adjusted some display strings to be independant of the Qt version (Qt4/Qt5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
118 Private method to get the source code for Qt4/Qt5.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 @param indLevel indentation level (int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @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
122 @return generated code (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 # calculate our indentation level and the indentation string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 il = indLevel + 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 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
127 estring = os.linesep + indLevel * indString
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 # 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138
3124
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3119
diff changeset
139 resvar = self.eResultVar.text()
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3119
diff changeset
140 if not resvar:
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3119
diff changeset
141 resvar = "result"
a01e410893ac Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3119
diff changeset
142 code = '{0}, ok = QInputDialog.'.format(resvar)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 if self.rText.isChecked():
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
144 code += 'getText({0}{1}'.format(os.linesep, istring)
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
145 code += '{0},{1}{2}'.format(parent, os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
146 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
147 self.eCaption.text(), os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
148 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
149 self.eLabel.text(), os.linesep, istring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if self.rEchoNormal.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 code += 'QLineEdit.Normal'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 elif self.rEchoNoEcho.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 code += 'QLineEdit.NoEcho'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 code += 'QLineEdit.Password'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 if self.eTextDefault.text():
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
157 code += ',{0}{1}self.tr("{2}")'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
158 os.linesep, istring, self.eTextDefault.text())
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
159 code += '){0}'.format(estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 elif self.rInteger.isChecked():
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
161 code += 'getInt({0}{1}'.format(os.linesep, istring)
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
162 code += '{0},{1}{2}'.format(parent, os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
163 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
164 self.eCaption.text(), os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
165 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
166 self.eLabel.text(), os.linesep, istring)
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
167 code += '{0:d}, {1:d}, {2:d}, {3:d}){4}'.format(
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
168 self.sIntDefault.value(), self.sIntFrom.value(),
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
169 self.sIntTo.value(), self.sIntStep.value(), estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 elif self.rDouble.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 doubleDefault = float(self.eDoubleDefault.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 doubleDefault = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 doubleFrom = float(self.eDoubleFrom.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 doubleFrom = -2147483647
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 doubleTo = float(self.eDoubleTo.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 doubleTo = 2147483647
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
183 code += 'getDouble({0}{1}'.format(os.linesep, istring)
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
184 code += '{0},{1}{2}'.format(parent, os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
185 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
186 self.eCaption.text(), os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
187 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
188 self.eLabel.text(), os.linesep, istring)
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
189 code += '{0}, {1}, {2}, {3:d}){4}'.format(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
190 doubleDefault, doubleFrom, doubleTo,
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
191 self.sDoubleDecimals.value(), estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 elif self.rItem.isChecked():
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
193 code += 'getItem({0}{1}'.format(os.linesep, istring)
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
194 code += '{0},{1}{2}'.format(parent, os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
195 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
196 self.eCaption.text(), os.linesep, istring)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
197 code += 'self.tr("{0}"),{1}{2}'.format(
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
198 self.eLabel.text(), os.linesep, istring)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
199 code += '{0},{1}{2}'.format(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
200 self.eVariable.text(), os.linesep, istring)
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
201 code += '{0:d}, {1}){2}'.format(
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
202 self.sCurrentItem.value(), self.cEditable.isChecked(), estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 return code

eric ide

mercurial