ProjectPyramid/FormSelectionDialog.py

changeset 18
c27d4435675a
parent 2
e691c51ab655
child 19
f4adfe6e51b0
--- a/ProjectPyramid/FormSelectionDialog.py	Thu Aug 30 14:34:35 2012 +0200
+++ b/ProjectPyramid/FormSelectionDialog.py	Thu Aug 30 15:36:06 2012 +0200
@@ -39,10 +39,67 @@
                 '''  </body>\n'''
                 '''</html>\n'''
                 ], 
+            "simple" : [self.trUtf8("Standard HTML template"), 
+                '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"\n'''
+                ''' "http://www.w3.org/TR/html4/strict.dtd">\n'''
+                '''  <head>\n'''
+                '''    <title></title>\n'''
+                '''    <style>\n'''
+                '''    </style>\n'''
+                '''  </head>\n'''
+                '''\n'''
+                '''  <body>\n'''
+                '''  </body>\n'''
+                '''</html>\n'''
+                ], 
+            "complex" : [self.trUtf8("Chameleon template"), 
+                '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n'''
+                ''' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'''
+                '''<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"\n'''
+                '''      xmlns:tal="http://xml.zope.org/namespaces/tal">\n'''
+                '''      xmlns:metal="http://xml.zope.org/namespaces/metal">\n'''
+                '''<head>\n'''
+                '''  <title>The Pyramid Web Application Development Framework</title>\n'''
+                '''  <meta http-equiv="Content-Type"\n'''
+                '''    content="text/html;charset=UTF-8"/>\n'''
+                '''  <meta name="keywords" content="python web application" />\n'''
+                '''  <meta name="description" content="pyramid web application" />\n'''
+                '''  <link rel="shortcut icon"\n'''
+                '''    href="${request.static_url('site:static/favicon.ico')}" />\n'''
+                '''  <link rel="stylesheet"\n'''
+                '''    href="${request.static_url('site:static/pylons.css')}"\n'''
+                '''    type="text/css" media="screen" charset="utf-8" />\n'''
+                '''  <link rel="stylesheet"\n'''
+                '''    href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css"\n'''
+                '''    media="screen" />\n'''
+                '''  <link rel="stylesheet"\n'''
+                '''    href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css"\n'''
+                '''    media="screen" />\n'''
+                '''  <!--[if lte IE 6]>\n'''
+                '''  <link rel="stylesheet"\n'''
+                '''    href="${request.static_url('site:static/ie6.css')}"\n'''
+                '''    type="text/css" media="screen" charset="utf-8" />\n'''
+                '''  <![endif]-->\n'''
+                '''</head>\n'''
+                '''<body>\n'''
+                '''  <div id="wrap">\n'''
+                '''    <div id="top">\n'''
+                '''    </div>\n'''
+                '''    <div id="middle">\n'''
+                '''    </div>\n'''
+                '''    <div id="bottom">\n'''
+                '''    </div>\n'''
+                '''  </div>\n'''
+                '''  <div id="footer">\n'''
+                '''    <div class="footer">&copy; Copyright 2012, Somebody.</div>\n'''
+                '''  </div>\n'''
+                '''</body>\n'''
+                '''</html>\n'''
+                ], 
             "sections" : [self.trUtf8("Mako template with sections"), 
                 '''## -*- coding: utf-8 -*-\n'''
                 '''\n'''
-                '''<!DOCTYPE HTML>\n'''
+                '''<!DOCTYPE html>\n'''
                 '''<html>\n'''
                 '''<head>\n'''
                 '''    <title>${self.title()}</title>\n'''
@@ -73,10 +130,13 @@
         self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
         self.__okButton.setEnabled(False)
         
+        templates = {}
+        for templateType in self.__templates:
+            templates[self.__templates[templateType][0]] = templateType
+        
         self.typeCombo.addItem("")
-        for templateType in self.templates:
-            self.typeCombo.addItem(self.templates[templateType][0], 
-                                   templateType)
+        for templateString, templateType in sorted(templates.items()):
+            self.typeCombo.addItem(templateString, templateType)
         self.typeCombo.setCurrentIndex(0)
     
     @pyqtSlot(int)
@@ -88,7 +148,7 @@
         """
         templateType = self.typeCombo.itemData(index)
         if templateType:
-            self.preview.setPlainText(self.templates[templateType][1])
+            self.preview.setPlainText(self.__templates[templateType][1])
             self.__okButton.setEnabled(True)
         else:
             self.preview.clear()
@@ -101,4 +161,4 @@
         @return text of the template (string)
         """
         templateType = self.typeCombo.itemData(self.typeCombo.currentIndex())
-        return self.templates[templateType][1]
+        return self.__templates[templateType][1]

eric ide

mercurial