ProjectPyramid/FormSelectionDialog.py

branch
eric7
changeset 147
eb28b4b6f7f5
parent 144
5c3684ee818e
child 156
62170c2682a3
equal deleted inserted replaced
146:7d955b1995d5 147:eb28b4b6f7f5
5 5
6 """ 6 """
7 Module implementing a dialog to select the template type. 7 Module implementing a dialog to select the template type.
8 """ 8 """
9 9
10 from PyQt5.QtCore import pyqtSlot 10 from PyQt6.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
12 12
13 from .Ui_FormSelectionDialog import Ui_FormSelectionDialog 13 from .Ui_FormSelectionDialog import Ui_FormSelectionDialog
14 14
15 15
16 class FormSelectionDialog(QDialog, Ui_FormSelectionDialog): 16 class FormSelectionDialog(QDialog, Ui_FormSelectionDialog):
19 """ 19 """
20 def __init__(self, parent=None): 20 def __init__(self, parent=None):
21 """ 21 """
22 Constructor 22 Constructor
23 23
24 @param parent reference to the parent widget (QWidget) 24 @param parent reference to the parent widget
25 @type QWidget
25 """ 26 """
26 super().__init__(parent) 27 super().__init__(parent)
27 self.setupUi(self) 28 self.setupUi(self)
28 29
29 self.__templates = { 30 self.__templates = {
142 '''<%def name="footer()"><p><a href="#top">Top ^</a></p>''' 143 '''<%def name="footer()"><p><a href="#top">Top ^</a></p>'''
143 '''</%def>\n''' 144 '''</%def>\n'''
144 ], 145 ],
145 } 146 }
146 147
147 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) 148 self.__okButton = self.buttonBox.button(
149 QDialogButtonBox.StandardButton.Ok)
148 self.__okButton.setEnabled(False) 150 self.__okButton.setEnabled(False)
149 151
150 templates = {} 152 templates = {}
151 for templateType in self.__templates: 153 for templateType in self.__templates:
152 templates[self.__templates[templateType][0]] = templateType 154 templates[self.__templates[templateType][0]] = templateType
159 @pyqtSlot(int) 161 @pyqtSlot(int)
160 def on_typeCombo_currentIndexChanged(self, index): 162 def on_typeCombo_currentIndexChanged(self, index):
161 """ 163 """
162 Private slot to act upon a change of the selected template type. 164 Private slot to act upon a change of the selected template type.
163 165
164 @param index selected index (integer) 166 @param index selected index
167 @type int
165 """ 168 """
166 templateType = self.typeCombo.itemData(index) 169 templateType = self.typeCombo.itemData(index)
167 if templateType: 170 if templateType:
168 self.preview.setPlainText(self.__templates[templateType][1]) 171 self.preview.setPlainText(self.__templates[templateType][1])
169 self.__okButton.setEnabled(True) 172 self.__okButton.setEnabled(True)
173 176
174 def getTemplateText(self): 177 def getTemplateText(self):
175 """ 178 """
176 Public method to get the template text. 179 Public method to get the template text.
177 180
178 @return text of the template (string) 181 @return text of the template
182 @rtype str
179 """ 183 """
180 templateType = self.typeCombo.itemData(self.typeCombo.currentIndex()) 184 templateType = self.typeCombo.itemData(self.typeCombo.currentIndex())
181 return self.__templates[templateType][1] 185 return self.__templates[templateType][1]

eric ide

mercurial