本文整理汇总了Python中PyQt5.QtPrintSupport.QPrintDialog.setOptions方法的典型用法代码示例。如果您正苦于以下问题:Python QPrintDialog.setOptions方法的具体用法?Python QPrintDialog.setOptions怎么用?Python QPrintDialog.setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtPrintSupport.QPrintDialog
的用法示例。
在下文中一共展示了QPrintDialog.setOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintDialog import setOptions [as 别名]
def print_(self):
printer = QPrinter()
dlg = QPrintDialog(printer, self)
dlg.setWindowTitle(app.caption(_("Print")))
options = (QAbstractPrintDialog.PrintToFile
| QAbstractPrintDialog.PrintShowPageSize
| QAbstractPrintDialog.PrintPageRange)
if self.browser.textCursor().hasSelection():
options |= QAbstractPrintDialog.PrintSelection
dlg.setOptions(options)
if dlg.exec_():
self.browser.print_(printer)
示例2: printSource
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintDialog import setOptions [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)