本文整理汇总了Python中PyQt4.QtGui.QTextDocument方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QTextDocument方法的具体用法?Python QtGui.QTextDocument怎么用?Python QtGui.QTextDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QTextDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_result
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def print_result(self):
if "HTML" in self.result:
data=QtCore.QFile("ar/style.css");
if (data.open(QtCore.QFile.ReadOnly)):
mySTYLE_SHEET=QtCore.QTextStream(data).readAll();
## text=unicode(text);
else:
mySTYLE_SHEET=u"""
body {
direction: rtl;
font-family: Traditional Arabic, "Times New Roman";
font-size: 16pt;
}
"""
document = QtGui.QTextDocument("")
document.setDefaultStyleSheet(mySTYLE_SHEET)
self.result["HTML"]=u"<html dir=rtl><body dir='rtl'>"+self.result["HTML"]+"</body></html>"
document.setHtml(self.result["HTML"]);
printer = QtGui.QPrinter()
dlg = QtGui.QPrintDialog(printer, self.centralwidget)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
self.ResultVocalized.print_(printer)
else:
QtGui.QMessageBox.warning(self.centralwidget,U"خطأ",
u"لا شيء يمكن طبعه.")
示例2: init_print
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def init_print(self, linenos=True, style="default"):
app = QApplication(sys.argv) # noqa
doc = QTextDocument()
doc.setHtml(
self.highlight_file(linenos=linenos, style=style)
)
printer = QPrinter()
printer.setOutputFileName(self.pdf_file)
printer.setOutputFormat(QPrinter.PdfFormat)
page_size_dict = {"a2": QPrinter.A2, "a3": QPrinter.A3, "a4": QPrinter.A4}
printer.setPageSize(page_size_dict.get(self.size.lower(), QPrinter.A4))
printer.setPageMargins(15, 15, 15, 15, QPrinter.Millimeter)
doc.print_(printer)
logging.info("PDF created at %s" % (self.pdf_file))
示例3: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def __init__(self, parent=None):
super(HTMLDelegate, self).__init__(parent)
self.doc = qg.QTextDocument(self)
示例4: createWidget
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def createWidget(self, style, listWidget, chat_msg,uin,flag=0,g_sender=None):
self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
self.listWidgetItem.setSizeHint(QtCore.QSize(0, 50))
self.widget = QtGui.QWidget()
self.graphicsView = QtGui.QGraphicsView(self.widget)
self.label = QtGui.QTextBrowser(self.widget)
self.label.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
orient=''
if flag==0:
ruin=uin
else:
ruin=g_sender
print 'img senderuin:',ruin
if style == 0:
self.widget.setGeometry(QtCore.QRect(0, 10, 455, 50))
self.graphicsView.setGeometry(QtCore.QRect(5, 5, 60, 60))
self.graphicsView.setScene(self.createImg(ruin,flag,g_sender))
self.graphicsView.resize(50,50)
self.label.setGeometry(QtCore.QRect(50, 5, 390, 50))
orient='left'
elif style == 1:
self.widget.setGeometry(QtCore.QRect(0, 10, 455, 50))
self.graphicsView.setGeometry(QtCore.QRect(392, 5, 60, 60))
self.graphicsView.setScene(self.createImg(ruin,flag,g_sender))
self.graphicsView.resize(50,50)
self.label.setGeometry(QtCore.QRect(10, 5, 390, 50))
orient='right'
# msg edit
if flag==1:
nick=self.groupInfo[uin][g_sender]['nick']
if flag==2:
nick=self.discussInfo[uin][g_sender]['nick']
if flag==1 or flag==2:
chat_msg=u'<p><b>'+nick+'</b></p><p>'+chat_msg+'</p>'
content = u'''
<html><body><p align="'''+orient+'''"> ''' + chat_msg + '''</p></body></html>
'''
doc = QtGui.QTextDocument(self.label)
doc.setHtml(content)
self.label.setDocument(doc)
# resize
size = max(self.label.document().size().height() + 5, 50)
self.listWidgetItem.setSizeHint(QtCore.QSize(445, size))
self.widget.resize(455, size)
self.label.resize(380, size)
return self.listWidgetItem, self.widget