本文整理汇总了Python中PyQt5.QtPrintSupport.QPrintDialog方法的典型用法代码示例。如果您正苦于以下问题:Python QtPrintSupport.QPrintDialog方法的具体用法?Python QtPrintSupport.QPrintDialog怎么用?Python QtPrintSupport.QPrintDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtPrintSupport
的用法示例。
在下文中一共展示了QtPrintSupport.QPrintDialog方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_dialog
# 需要导入模块: from PyQt5 import QtPrintSupport [as 别名]
# 或者: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
def show_dialog(self) -> None:
"""Print with a QPrintDialog."""
self.check_printer_support()
def print_callback(ok: bool) -> None:
"""Called when printing finished."""
if not ok:
message.error("Printing failed!")
diag.deleteLater()
def do_print() -> None:
"""Called when the dialog was closed."""
self.to_printer(diag.printer(), print_callback)
diag = QPrintDialog(self._tab)
if utils.is_mac:
# For some reason we get a segfault when using open() on macOS
ret = diag.exec_()
if ret == QDialog.Accepted:
do_print()
else:
diag.open(do_print)
示例2: run
# 需要导入模块: from PyQt5 import QtPrintSupport [as 别名]
# 或者: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
def run(self, *args, **kwargs):
"""
Print the diagram.
"""
shape = self.diagram.visibleRect(margin=20)
if shape:
printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.HighResolution)
printer.setOutputFormat(QtPrintSupport.QPrinter.NativeFormat)
dialog = QtPrintSupport.QPrintDialog(printer)
if dialog.exec_() == QtPrintSupport.QPrintDialog.Accepted:
painter = QtGui.QPainter()
if painter.begin(printer):
# TURN CACHING OFF
for item in self.diagram.items():
if item.isNode() or item.isEdge():
item.setCacheMode(AbstractItem.NoCache)
# RENDER THE DIAGRAM IN THE PAINTER
self.diagram.render(painter, source=shape)
# TURN CACHING ON
for item in self.diagram.items():
if item.isNode() or item.isEdge():
item.setCacheMode(AbstractItem.DeviceCoordinateCache)
# COMPLETE THE PRINT
painter.end()
示例3: onPrint
# 需要导入模块: from PyQt5 import QtPrintSupport [as 别名]
# 或者: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
def onPrint(self):
doc = QsciPrinter()
dialog = QPrintDialog(doc, self)
dialog.setWindowTitle('Print')
if (dialog.exec_() == QDialog.Accepted):
self.textPad.setPythonPrintStyle()
try:
doc.printRange(self.textPad)
except Exception as e:
print(str(e))
else:
return
self.textPad.setPythonStyle()
示例4: on_print_requested
# 需要导入模块: from PyQt5 import QtPrintSupport [as 别名]
# 或者: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
def on_print_requested(self, frame):
"""Handle printing when requested via javascript."""
printdiag = QPrintDialog()
printdiag.setAttribute(Qt.WA_DeleteOnClose)
printdiag.open(lambda: frame.print(printdiag.printer()))
示例5: printHandler
# 需要导入模块: from PyQt5 import QtPrintSupport [as 别名]
# 或者: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
def printHandler(self):
# Open printing dialog
dialog = QtPrintSupport.QPrintDialog()
if dialog.exec_() == QtWidgets.QDialog.Accepted:
self.text.document().print_(dialog.printer())
示例6: print_dialog
# 需要导入模块: from PyQt5 import QtPrintSupport [as 别名]
# 或者: from PyQt5.QtPrintSupport import QPrintDialog [as 别名]
def print_dialog(self):
# Errata: the book contained this line:
#self._print_document()
# As noted by DevinLand in issue #8, this can cause the document to start printing.
dialog = qtps.QPrintDialog(self.printer, self)
# Instead we'll add this line, so _print_document is triggered when the dialog is
# accepted:
dialog.accepted.connect(self._print_document)
dialog.exec()
self._update_preview_size()
开发者ID:PacktPublishing,项目名称:Mastering-GUI-Programming-with-Python,代码行数:13,代码来源:invoice_maker_printable.py