本文整理匯總了Python中PyQt4.QtGui.QPrintDialog.printRange方法的典型用法代碼示例。如果您正苦於以下問題:Python QPrintDialog.printRange方法的具體用法?Python QPrintDialog.printRange怎麽用?Python QPrintDialog.printRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtGui.QPrintDialog
的用法示例。
在下文中一共展示了QPrintDialog.printRange方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: printFile
# 需要導入模塊: from PyQt4.QtGui import QPrintDialog [as 別名]
# 或者: from PyQt4.QtGui.QPrintDialog import printRange [as 別名]
def printFile(self):
"""Print file
"""
printer = QsciPrinter()
# set wrapmode
printer.setWrapMode(QsciScintilla.WrapWord)
dialog = QPrintDialog (printer)
if dialog.exec_() == dialog.Accepted:
if dialog.printRange() == dialog.Selection:
f, unused, t, unused1 = self.qscintilla.getSelection()
else:
f = -1
t = -1
printer.printRange(self.qscintilla, f, t)
示例2: printSource
# 需要導入模塊: from PyQt4.QtGui import QPrintDialog [as 別名]
# 或者: from PyQt4.QtGui.QPrintDialog import printRange [as 別名]
def printSource(self):
cursor = self.textCursor()
try:
printer = self._sourcePrinter
except AttributeError:
printer = self._sourcePrinter = QPrinter()
else:
printer.setCopyCount(1)
dlg = QPrintDialog(printer, self)
dlg.setWindowTitle(app.caption(_("dialog title", "Print Source")))
options = QAbstractPrintDialog.PrintToFile | QAbstractPrintDialog.PrintShowPageSize
if cursor.hasSelection():
options |= QAbstractPrintDialog.PrintSelection
dlg.setOptions(options)
if dlg.exec_():
if dlg.printRange() != QAbstractPrintDialog.Selection:
cursor.clearSelection()
number_lines = QSettings().value("source_export/number_lines", False, bool)
doc = highlighter.html_copy(cursor, 'printer', number_lines)
doc.setMetaInformation(QTextDocument.DocumentTitle, self.currentDocument().url().toString())
font = doc.defaultFont()
font.setPointSizeF(font.pointSizeF() * 0.8)
doc.setDefaultFont(font)
doc.print_(printer)