Пример #1
0
 def complex_document(self, nodes, heads=False):
     """Create a complex document."""
     doc = QtGui.QTextDocument()
     doc.setDefaultStyleSheet(self.stylesheet)
     contents = ''
     for n in nodes:
         if heads:
             contents += '<h1>%s</h1>\n' % (self.sanitize_html(n.h))
         contents += '<pre>%s</pre>\n' % (self.sanitize_html(n.b))
     doc.setHtml(contents)
     return doc
Пример #2
0
 def document(self, text, head=None):
     """Create a Qt document."""
     doc = QtGui.QTextDocument()
     doc.setDefaultStyleSheet(self.stylesheet)
     text = self.sanitize_html(text)
     if head:
         head = self.sanitize_html(head)
         contents = "<h1>%s</h1>\n<pre>%s</pre>" % (head, text)
     else:
         contents = f"<pre>{text}<pre>"
     doc.setHtml(contents)
     return doc
Пример #3
0
 def html_document(self, text):
     """Create an HTML document."""
     doc = QtGui.QTextDocument()
     doc.setDefaultStyleSheet(self.stylesheet)
     doc.setHtml(text)
     return doc