本文整理汇总了Python中PyQt5.QtPrintSupport.QPrintPreviewDialog.exec方法的典型用法代码示例。如果您正苦于以下问题:Python QPrintPreviewDialog.exec方法的具体用法?Python QPrintPreviewDialog.exec怎么用?Python QPrintPreviewDialog.exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtPrintSupport.QPrintPreviewDialog
的用法示例。
在下文中一共展示了QPrintPreviewDialog.exec方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printPreview
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec [as 别名]
def printPreview(self):
document = self.getDocumentForPrint()
if document == None:
return
printer = self.standardPrinter()
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested.connect(document.print)
preview.exec()
示例2: printPreview
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec [as 别名]
def printPreview(self):
title, htmltext, preview = self.currentTab.getDocumentForExport(includeStyleSheet=True,
webenv=False)
document = self.getDocumentForPrint(title, htmltext, preview)
if document is None:
return
printer = self.standardPrinter(title)
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested.connect(document.print)
preview.exec()
示例3: __init__
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec [as 别名]
def __init__(self, parent=None, html=None):
super(PrintHtml, self).__init__(parent)
# html = codecs.open(b"template.html", encoding='utf-8').read()
baseurl = QUrl.fromLocalFile(os.getcwd() + "/temp/index.html")
self.setHtml(html, baseurl)
self.printer = QPrinter()
self.printer.setPageSize(QPrinter.A4)
self.printer.setOrientation(QPrinter.Portrait)
self.printer.setPageMargins(5, 5, 5, 5, QPrinter.Millimeter)
self.setFixedWidth(1000)
dialog = QPrintPreviewDialog(self.printer)
dialog.setWindowState(Qt.WindowMaximized)
dialog.paintRequested.connect(self.print_)
dialog.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint | Qt.WindowContextHelpButtonHint)
dialog.exec()
示例4: HtmlView
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec [as 别名]
class HtmlView(QWebEngineView):
"""Subclass QWebView and connect to a QPrintPreviewDialog object"""
def __init__(self, parent=None, url = ""):
"""
Constructor of HtmlView
:param parent: parent of the view
:param url: url to load, if set, a loadFInished signal is emitted
"""
super().__init__(parent)
self.html = ""
self.setUrl(QUrl(url))
"""Open QPrintPreviewDialog dialog window"""
self.preview = QPrintPreviewDialog()
# just for the moment / buf in Qt leads to incorrect printing of tables fomr QWebKit
self.preview.printer().setOutputFormat(QPrinter.PdfFormat)
self.preview.printer().setPaperSize(QPrinter.A4)
self.textedit = QTextEdit()
self.preview.paintRequested.connect(self.printPreview)
if url != "":
self.loadFinished.connect(self.execpreview)
def execpreview(self, arg):
self.preview.exec()
def printPreview(self, printer):
self.textedit.print(printer)
def setHtml_(self, html):
self.setHtml(html)
self.textedit.setHtml(html)
# small workaround to find the QPrintPreviewWidget inside the pre-defined dialog and force it to update its content
wdg = self.preview.findChild(PyQt5.QtPrintSupport.QPrintPreviewWidget)
if wdg is not None:
wdg.updatePreview()