6 """ |
6 """ |
7 Module implementing a dialog for entering multiple template variables. |
7 Module implementing a dialog for entering multiple template variables. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import QSize, Qt |
10 from PyQt4.QtCore import QSize, Qt |
11 from PyQt4.QtGui import QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, QLineEdit, \ |
11 from PyQt4.QtGui import QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, \ |
12 QPushButton, QTextEdit, QDialog, QScrollArea, QFrame, QGridLayout, QVBoxLayout, QLabel |
12 QLineEdit, QPushButton, QTextEdit, QDialog, QScrollArea, QFrame, \ |
|
13 QGridLayout, QVBoxLayout, QLabel |
13 |
14 |
14 |
15 |
15 class TemplateMultipleVariablesDialog(QDialog): |
16 class TemplateMultipleVariablesDialog(QDialog): |
16 """ |
17 """ |
17 Class implementing a dialog for entering multiple template variables. |
18 Class implementing a dialog for entering multiple template variables. |
24 @param parent parent widget of this dialog (QWidget) |
25 @param parent parent widget of this dialog (QWidget) |
25 """ |
26 """ |
26 super().__init__(parent) |
27 super().__init__(parent) |
27 |
28 |
28 self.TemplateMultipleVariablesDialogLayout = QVBoxLayout(self) |
29 self.TemplateMultipleVariablesDialogLayout = QVBoxLayout(self) |
29 self.TemplateMultipleVariablesDialogLayout.setContentsMargins(6, 6, 6, 6) |
30 self.TemplateMultipleVariablesDialogLayout.setContentsMargins( |
|
31 6, 6, 6, 6) |
30 self.TemplateMultipleVariablesDialogLayout.setSpacing(6) |
32 self.TemplateMultipleVariablesDialogLayout.setSpacing(6) |
31 self.TemplateMultipleVariablesDialogLayout.setObjectName( |
33 self.TemplateMultipleVariablesDialogLayout.setObjectName( |
32 "TemplateMultipleVariablesDialogLayout") |
34 "TemplateMultipleVariablesDialogLayout") |
33 self.setLayout(self.TemplateMultipleVariablesDialogLayout) |
35 self.setLayout(self.TemplateMultipleVariablesDialogLayout) |
34 |
36 |
35 # generate the scrollarea |
37 # generate the scrollarea |
36 self.variablesView = QScrollArea(self) |
38 self.variablesView = QScrollArea(self) |
37 self.variablesView.setObjectName("variablesView") |
39 self.variablesView.setObjectName("variablesView") |
38 self.TemplateMultipleVariablesDialogLayout.addWidget(self.variablesView) |
40 self.TemplateMultipleVariablesDialogLayout.addWidget( |
|
41 self.variablesView) |
39 |
42 |
40 self.variablesView.setWidgetResizable(True) |
43 self.variablesView.setWidgetResizable(True) |
41 self.variablesView.setFrameStyle(QFrame.NoFrame) |
44 self.variablesView.setFrameStyle(QFrame.NoFrame) |
42 |
45 |
43 self.top = QWidget(self) |
46 self.top = QWidget(self) |
64 t = QLineEdit(self.top) |
67 t = QLineEdit(self.top) |
65 self.grid.addWidget(t, row, 1) |
68 self.grid.addWidget(t, row, 1) |
66 self.variablesEntries[var] = t |
69 self.variablesEntries[var] = t |
67 row += 1 |
70 row += 1 |
68 # add a spacer to make the entries aligned at the top |
71 # add a spacer to make the entries aligned at the top |
69 spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) |
72 spacer = QSpacerItem( |
|
73 20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) |
70 self.grid.addItem(spacer, row, 1) |
74 self.grid.addItem(spacer, row, 1) |
71 self.variablesEntries[variables[0]].setFocus() |
75 self.variablesEntries[variables[0]].setFocus() |
72 self.top.adjustSize() |
76 self.top.adjustSize() |
73 |
77 |
74 # generate the buttons |
78 # generate the buttons |
75 layout1 = QHBoxLayout() |
79 layout1 = QHBoxLayout() |
76 layout1.setContentsMargins(0, 0, 0, 0) |
80 layout1.setContentsMargins(0, 0, 0, 0) |
77 layout1.setSpacing(6) |
81 layout1.setSpacing(6) |
78 layout1.setObjectName("layout1") |
82 layout1.setObjectName("layout1") |
79 |
83 |
80 spacer1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) |
84 spacer1 = QSpacerItem( |
|
85 40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) |
81 layout1.addItem(spacer1) |
86 layout1.addItem(spacer1) |
82 |
87 |
83 self.okButton = QPushButton(self) |
88 self.okButton = QPushButton(self) |
84 self.okButton.setObjectName("okButton") |
89 self.okButton.setObjectName("okButton") |
85 self.okButton.setDefault(True) |
90 self.okButton.setDefault(True) |
87 |
92 |
88 self.cancelButton = QPushButton(self) |
93 self.cancelButton = QPushButton(self) |
89 self.cancelButton.setObjectName("cancelButton") |
94 self.cancelButton.setObjectName("cancelButton") |
90 layout1.addWidget(self.cancelButton) |
95 layout1.addWidget(self.cancelButton) |
91 |
96 |
92 spacer2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) |
97 spacer2 = QSpacerItem( |
|
98 40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) |
93 layout1.addItem(spacer2) |
99 layout1.addItem(spacer2) |
94 |
100 |
95 self.TemplateMultipleVariablesDialogLayout.addLayout(layout1) |
101 self.TemplateMultipleVariablesDialogLayout.addLayout(layout1) |
96 |
102 |
97 # set the texts of the standard widgets |
103 # set the texts of the standard widgets |