本文整理汇总了Python中PyQt4.QtGui.QTextCursor.currentFrame方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.currentFrame方法的具体用法?Python QTextCursor.currentFrame怎么用?Python QTextCursor.currentFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.currentFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printDocument2
# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import currentFrame [as 别名]
def printDocument2(self):
dialog = QPrintDialog()
if not dialog.exec_():
return
self.printer = dialog.printer()
headFormat = QTextBlockFormat()
headFormat.setAlignment(Qt.AlignLeft)
headFormat.setTextIndent(
self.printer.pageRect().width()-216)
bodyFormat = QTextBlockFormat()
bodyFormat.setAlignment(Qt.AlignJustify)
lastParaBodyFormat = QTextBlockFormat(bodyFormat)
lastParaBodyFormat.setPageBreakPolicy(QTextFormat.PageBreak_AlwaysAfter)
rightBodyFormat = QTextBlockFormat()
rightBodyFormat.setAlignment(Qt.AlignRight)
headCharFormat = QTextCharFormat()
headCharFormat.setFont(QFont("Helvetica",10))
bodyCharFormat = QTextCharFormat()
bodyCharFormat.setFont(QFont("Times",11))
redBodyCharFormat = QTextCharFormat(bodyCharFormat)
redBodyCharFormat.setForeground(Qt.red)
tableFormat = QTextTableFormat()
tableFormat.setBorder(1)
tableFormat.setCellPadding(2)
document = QTextDocument()
cursor = QTextCursor(document)
mainFrame = cursor.currentFrame()
page = 1
cursor.insertBlock(headFormat, headCharFormat)
for text in ("Greasy Hands Ltd.", "New Lombard Street","London" , "WC13", QDate.currentDate().toString(self.DATE_FORMAT)):
cursor.insertBlock(headFormat,headCharFormat)
cursor.insertText(text)
cursor.insertBlock(bodyFormat,bodyCharFormat)
cursor.insertText("Barrio Francisco Meza")
cursor.insertBlock(bodyFormat)
cursor.insertBlock(bodyFormat,bodyCharFormat)
cursor.insertText("Dear Lyuis")
cursor.insertBlock(bodyFormat)
cursor.insertBlock(bodyFormat,bodyCharFormat)
cursor.insertText(QString("The balance of your account is $ %L1.").arg(float(500.987),0,"f",2))
cursor.insertBlock(bodyFormat,redBodyCharFormat)
cursor.insertText("Please remit the amount")
cursor.insertBlock(bodyFormat,bodyCharFormat)
cursor.insertText("Transaction")
transactions = [
(QDate.currentDate(),500),
(QDate.currentDate(),500),
(QDate.currentDate(),-500),
(QDate.currentDate(),500)
]
table = cursor.insertTable(len(transactions), 3, tableFormat)
row = 0
for date, amount in transactions:
cellCursor = table.cellAt(row,0).firstCursorPosition()
cellCursor.setBlockFormat(rightBodyFormat)
cellCursor.insertText(date.toString(self.DATE_FORMAT),bodyCharFormat)
cellCursor = table.cellAt(row,1).firstCursorPosition()
cellCursor.insertText("Credit",bodyCharFormat)
cellCursor = table.cellAt(row,2).firstCursorPosition()
cellCursor.setBlockFormat(rightBodyFormat)
cellCursor.insertText(QString("The balance of your account is $ %L1.").arg(float(amount),0,"f",2),redBodyCharFormat)
row += 1
cursor.setPosition(mainFrame.lastPosition())
cursor.insertBlock(bodyFormat,bodyCharFormat)
cursor.insertText("We hope")
document.print_(self.printer)