本文整理汇总了Python中PyQt4.QtGui.QTextDocument.defaultFont方法的典型用法代码示例。如果您正苦于以下问题:Python QTextDocument.defaultFont方法的具体用法?Python QTextDocument.defaultFont怎么用?Python QTextDocument.defaultFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTextDocument
的用法示例。
在下文中一共展示了QTextDocument.defaultFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PyQt4.QtGui import QTextDocument [as 别名]
# 或者: from PyQt4.QtGui.QTextDocument import defaultFont [as 别名]
def main():
app = QApplication(sys.argv)
# Preparing the pdf
doc = QTextDocument()
printer = QPrinter()
printer.setOutputFileName("KabitGurdas.pdf")
printer.setOutputFormat(QPrinter.PdfFormat)
# Setting page size as A5
printer.setPaperSize(QPrinter.A5);
# page margin
printer.setPageMargins(12, 16, 12, 20, QPrinter.Millimeter)
doc.setPageSize(QSizeF(printer.pageRect().size()))
painter = QPainter()
painter.begin( printer )
# Set poem book and get each poem in pdf
book = kb()
for KabitNumber in range(1,676):
# Add text in html to page
doc.setHtml(book.getKabitHTML(KabitNumber))
doc.defaultFont().setPointSize(20)
# A new page
printer.newPage()
# Create a QPainter to draw our content
doc.drawContents(painter)#,printer.pageRect().translated( -printer.pageRect().x(), -printer.pageRect().y() ))
#QTextDocument.drawContents(QPainter, QRectF rect=QRectF())
doc.print_(printer)
# Done.
painter.end()