ProjectDjangoTagsMenu/IfTagInputDialog.py

branch
eric7
changeset 63
85418cf03fdb
parent 60
85d3931419d3
child 69
9acb6987ce60
equal deleted inserted replaced
62:dba433b4f3d6 63:85418cf03fdb
15 15
16 class IfTagInputDialog(QDialog, Ui_IfTagInputDialog): 16 class IfTagInputDialog(QDialog, Ui_IfTagInputDialog):
17 """ 17 """
18 Class implementing a dialog to enter the parameters for the if tag. 18 Class implementing a dialog to enter the parameters for the if tag.
19 """ 19 """
20
20 def __init__(self, parent=None): 21 def __init__(self, parent=None):
21 """ 22 """
22 Constructor 23 Constructor
23 24
24 @param parent reference to the parent widget 25 @param parent reference to the parent widget
25 @type QWidget 26 @type QWidget
26 """ 27 """
27 super().__init__(parent) 28 super().__init__(parent)
28 self.setupUi(self) 29 self.setupUi(self)
29 30
30 self.buttonBox.button( 31 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
31 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 32
32
33 @pyqtSlot(str) 33 @pyqtSlot(str)
34 def on_ifEdit_textChanged(self, txt): 34 def on_ifEdit_textChanged(self, txt):
35 """ 35 """
36 Private slot to handle changes of the 'if' expression. 36 Private slot to handle changes of the 'if' expression.
37 37
38 @param txt text of the line edit 38 @param txt text of the line edit
39 @type str 39 @type str
40 """ 40 """
41 self.buttonBox.button( 41 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt))
42 QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) 42
43
44 def getTag(self): 43 def getTag(self):
45 """ 44 """
46 Public method to retrieve the tag. 45 Public method to retrieve the tag.
47 46
48 @return tag 47 @return tag
49 @rtype str 48 @rtype str
50 """ 49 """
51 tag = '{{% if {0} %}}\n'.format(self.ifEdit.text()) 50 tag = "{{% if {0} %}}\n".format(self.ifEdit.text())
52 elifText = self.elifEdit.toPlainText() 51 elifText = self.elifEdit.toPlainText()
53 if elifText: 52 if elifText:
54 for expression in elifText.splitlines(): 53 for expression in elifText.splitlines():
55 if expression.strip(): 54 if expression.strip():
56 tag += '{{% elif {0} %}}\n'.format(expression.strip()) 55 tag += "{{% elif {0} %}}\n".format(expression.strip())
57 if self.elseCheckBox.isChecked(): 56 if self.elseCheckBox.isChecked():
58 tag += '{% else %}\n' 57 tag += "{% else %}\n"
59 tag += '{% endif %}' 58 tag += "{% endif %}"
60 59
61 return tag 60 return tag

eric ide

mercurial