ProjectPyramid/FormSelectionDialog.py

changeset 18
c27d4435675a
parent 2
e691c51ab655
child 19
f4adfe6e51b0
equal deleted inserted replaced
17:55ab27883133 18:c27d4435675a
37 '''\n''' 37 '''\n'''
38 ''' <body>\n''' 38 ''' <body>\n'''
39 ''' </body>\n''' 39 ''' </body>\n'''
40 '''</html>\n''' 40 '''</html>\n'''
41 ], 41 ],
42 "simple" : [self.trUtf8("Standard HTML template"),
43 '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"\n'''
44 ''' "http://www.w3.org/TR/html4/strict.dtd">\n'''
45 ''' <head>\n'''
46 ''' <title></title>\n'''
47 ''' <style>\n'''
48 ''' </style>\n'''
49 ''' </head>\n'''
50 '''\n'''
51 ''' <body>\n'''
52 ''' </body>\n'''
53 '''</html>\n'''
54 ],
55 "complex" : [self.trUtf8("Chameleon template"),
56 '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n'''
57 ''' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'''
58 '''<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"\n'''
59 ''' xmlns:tal="http://xml.zope.org/namespaces/tal">\n'''
60 ''' xmlns:metal="http://xml.zope.org/namespaces/metal">\n'''
61 '''<head>\n'''
62 ''' <title>The Pyramid Web Application Development Framework</title>\n'''
63 ''' <meta http-equiv="Content-Type"\n'''
64 ''' content="text/html;charset=UTF-8"/>\n'''
65 ''' <meta name="keywords" content="python web application" />\n'''
66 ''' <meta name="description" content="pyramid web application" />\n'''
67 ''' <link rel="shortcut icon"\n'''
68 ''' href="${request.static_url('site:static/favicon.ico')}" />\n'''
69 ''' <link rel="stylesheet"\n'''
70 ''' href="${request.static_url('site:static/pylons.css')}"\n'''
71 ''' type="text/css" media="screen" charset="utf-8" />\n'''
72 ''' <link rel="stylesheet"\n'''
73 ''' href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css"\n'''
74 ''' media="screen" />\n'''
75 ''' <link rel="stylesheet"\n'''
76 ''' href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css"\n'''
77 ''' media="screen" />\n'''
78 ''' <!--[if lte IE 6]>\n'''
79 ''' <link rel="stylesheet"\n'''
80 ''' href="${request.static_url('site:static/ie6.css')}"\n'''
81 ''' type="text/css" media="screen" charset="utf-8" />\n'''
82 ''' <![endif]-->\n'''
83 '''</head>\n'''
84 '''<body>\n'''
85 ''' <div id="wrap">\n'''
86 ''' <div id="top">\n'''
87 ''' </div>\n'''
88 ''' <div id="middle">\n'''
89 ''' </div>\n'''
90 ''' <div id="bottom">\n'''
91 ''' </div>\n'''
92 ''' </div>\n'''
93 ''' <div id="footer">\n'''
94 ''' <div class="footer">&copy; Copyright 2012, Somebody.</div>\n'''
95 ''' </div>\n'''
96 '''</body>\n'''
97 '''</html>\n'''
98 ],
42 "sections" : [self.trUtf8("Mako template with sections"), 99 "sections" : [self.trUtf8("Mako template with sections"),
43 '''## -*- coding: utf-8 -*-\n''' 100 '''## -*- coding: utf-8 -*-\n'''
44 '''\n''' 101 '''\n'''
45 '''<!DOCTYPE HTML>\n''' 102 '''<!DOCTYPE html>\n'''
46 '''<html>\n''' 103 '''<html>\n'''
47 '''<head>\n''' 104 '''<head>\n'''
48 ''' <title>${self.title()}</title>\n''' 105 ''' <title>${self.title()}</title>\n'''
49 ''' ${self.head()}\n''' 106 ''' ${self.head()}\n'''
50 '''</head>\n''' 107 '''</head>\n'''
71 } 128 }
72 129
73 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) 130 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
74 self.__okButton.setEnabled(False) 131 self.__okButton.setEnabled(False)
75 132
133 templates = {}
134 for templateType in self.__templates:
135 templates[self.__templates[templateType][0]] = templateType
136
76 self.typeCombo.addItem("") 137 self.typeCombo.addItem("")
77 for templateType in self.templates: 138 for templateString, templateType in sorted(templates.items()):
78 self.typeCombo.addItem(self.templates[templateType][0], 139 self.typeCombo.addItem(templateString, templateType)
79 templateType)
80 self.typeCombo.setCurrentIndex(0) 140 self.typeCombo.setCurrentIndex(0)
81 141
82 @pyqtSlot(int) 142 @pyqtSlot(int)
83 def on_typeCombo_currentIndexChanged(self, index): 143 def on_typeCombo_currentIndexChanged(self, index):
84 """ 144 """
86 146
87 @param index selected index (integer) 147 @param index selected index (integer)
88 """ 148 """
89 templateType = self.typeCombo.itemData(index) 149 templateType = self.typeCombo.itemData(index)
90 if templateType: 150 if templateType:
91 self.preview.setPlainText(self.templates[templateType][1]) 151 self.preview.setPlainText(self.__templates[templateType][1])
92 self.__okButton.setEnabled(True) 152 self.__okButton.setEnabled(True)
93 else: 153 else:
94 self.preview.clear() 154 self.preview.clear()
95 self.__okButton.setEnabled(False) 155 self.__okButton.setEnabled(False)
96 156
99 Public method to get the template text. 159 Public method to get the template text.
100 160
101 @return text of the template (string) 161 @return text of the template (string)
102 """ 162 """
103 templateType = self.typeCombo.itemData(self.typeCombo.currentIndex()) 163 templateType = self.typeCombo.itemData(self.typeCombo.currentIndex())
104 return self.templates[templateType][1] 164 return self.__templates[templateType][1]

eric ide

mercurial