本文整理汇总了Python中PyQt5.QtPrintSupport.QPrintPreviewDialog.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QPrintPreviewDialog.exec_方法的具体用法?Python QPrintPreviewDialog.exec_怎么用?Python QPrintPreviewDialog.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtPrintSupport.QPrintPreviewDialog
的用法示例。
在下文中一共展示了QPrintPreviewDialog.exec_方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_file
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def print_file(fileName, printFunction):
"""This method print a file
This method print a file, fileName is the default fileName,
and printFunction is a funcion that takes a QPrinter
object and print the file,
the print method
More info on:http://doc.qt.nokia.com/latest/printing.html"""
printer = QPrinter(QPrinter.HighResolution)
printer.setPageSize(QPrinter.A4)
printer.setOutputFileName(fileName)
printer.setDocName(fileName)
preview = QPrintPreviewDialog(printer)
preview.paintRequested['QPrinter*'].connect(printFunction)
size = QApplication.instance().desktop().screenGeometry()
width = size.width() - 100
height = size.height() - 100
preview.setMinimumSize(width, height)
preview.exec_()
示例2: printpage
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def printpage(self, preview=False, count: {'special': 'count'}=None):
"""Print the current/[count]th tab.
Args:
preview: Show preview instead of printing.
count: The tab index to print, or None.
"""
if not qtutils.check_print_compat():
# WORKAROUND (remove this when we bump the requirements to 5.3.0)
raise cmdexc.CommandError(
"Printing on Qt < 5.3.0 on Windows is broken, please upgrade!")
tab = self._cntwidget(count)
if tab is not None:
if preview:
diag = QPrintPreviewDialog()
diag.setAttribute(Qt.WA_DeleteOnClose)
diag.setWindowFlags(diag.windowFlags() |
Qt.WindowMaximizeButtonHint |
Qt.WindowMinimizeButtonHint)
diag.paintRequested.connect(tab.print)
diag.exec_()
else:
diag = QPrintDialog()
diag.setAttribute(Qt.WA_DeleteOnClose)
diag.open(lambda: tab.print(diag.printer()))
示例3: __printPreviewDiagram
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def __printPreviewDiagram(self):
"""
Private slot called to show a print preview of the diagram.
"""
from PyQt5.QtPrintSupport import QPrintPreviewDialog
printer = QPrinter(mode=QPrinter.ScreenResolution)
printer.setFullPage(True)
if Preferences.getPrinter("ColorMode"):
printer.setColorMode(QPrinter.Color)
else:
printer.setColorMode(QPrinter.GrayScale)
if Preferences.getPrinter("FirstPageFirst"):
printer.setPageOrder(QPrinter.FirstPageFirst)
else:
printer.setPageOrder(QPrinter.LastPageFirst)
printer.setPageMargins(
Preferences.getPrinter("LeftMargin") * 10,
Preferences.getPrinter("TopMargin") * 10,
Preferences.getPrinter("RightMargin") * 10,
Preferences.getPrinter("BottomMargin") * 10,
QPrinter.Millimeter
)
printer.setPrinterName(Preferences.getPrinter("PrinterName"))
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested[QPrinter].connect(self.__print)
preview.exec_()
示例4: print_
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def print_(self):
printer = QPrinter(QPrinter.ScreenResolution)
dlg = QPrintPreviewDialog(printer)
view = PrintView()
view.setModel(self.table.model())
dlg.paintRequested.connect(view.print_)
dlg.exec_()
示例5: __printPreviewImage
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def __printPreviewImage(self):
"""
Private slot to handle the Print Preview menu action.
"""
from PyQt5.QtPrintSupport import QPrintPreviewDialog
if self.mainWidget is None:
E5MessageBox.critical(
self,
self.tr("Print Preview"),
self.tr("""There is no UI file loaded."""))
return
settings = Preferences.Prefs.settings
printer = QPrinter(QPrinter.HighResolution)
printer.setFullPage(True)
printerName = Preferences.getPrinter("UIPreviewer/printername")
if printerName:
printer.setPrinterName(printerName)
printer.setPageSize(
QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
printer.setPageOrder(
QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
printer.setOrientation(QPrinter.Orientation(
int(settings.value("UIPreviewer/orientation"))))
printer.setColorMode(
QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode"))))
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested.connect(self.__print)
preview.exec_()
示例6: printPreviewBrowser
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def printPreviewBrowser(self, browser=None):
"""
Public slot called to show a print preview of the displayed file.
@param browser reference to the browser to be printed (HelpBrowserWV)
"""
from PyQt5.QtPrintSupport import QPrintPreviewDialog
if browser is None:
browser = self.currentBrowser()
printer = QPrinter(mode=QPrinter.HighResolution)
if Preferences.getPrinter("ColorMode"):
printer.setColorMode(QPrinter.Color)
else:
printer.setColorMode(QPrinter.GrayScale)
if Preferences.getPrinter("FirstPageFirst"):
printer.setPageOrder(QPrinter.FirstPageFirst)
else:
printer.setPageOrder(QPrinter.LastPageFirst)
printer.setPageMargins(
Preferences.getPrinter("LeftMargin") * 10,
Preferences.getPrinter("TopMargin") * 10,
Preferences.getPrinter("RightMargin") * 10,
Preferences.getPrinter("BottomMargin") * 10,
QPrinter.Millimeter
)
printerName = Preferences.getPrinter("PrinterName")
if printerName:
printer.setPrinterName(printerName)
self.__printPreviewBrowser = browser
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested.connect(self.__printPreview)
preview.exec_()
示例7: _print_preview
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def _print_preview(tab: apitypes.Tab) -> None:
"""Show a print preview."""
def print_callback(ok: bool) -> None:
if not ok:
message.error("Printing failed!")
tab.printing.check_preview_support()
diag = QPrintPreviewDialog(tab)
diag.setAttribute(Qt.WA_DeleteOnClose)
diag.setWindowFlags(diag.windowFlags() | Qt.WindowMaximizeButtonHint |
Qt.WindowMinimizeButtonHint)
diag.paintRequested.connect(functools.partial(
tab.printing.to_printer, callback=print_callback))
diag.exec_()
示例8: printDocument
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def printDocument(self):
document = self.text.document()
printer = QPrinter()
dlg = QPrintPreviewDialog(printer, self)
if dlg.exec_() != QtWidgets.QDialog.Accepted:
return
document.print_(printer)
self.statusBar().showMessage("Печать успешна", 2000)
示例9: filePrintPreview
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def filePrintPreview(self):
printer = QPrinter(QPrinter.HighResolution)
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested.connect(self.printPreview)
preview.exec_()
示例10: printReview
# 需要导入模块: from PyQt5.QtPrintSupport import QPrintPreviewDialog [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrintPreviewDialog import exec_ [as 别名]
def printReview(self):
printer = QPrinter(QPrinter.HighResolution)
review = QPrintPreviewDialog(printer, self)
review.setWindowFlags(QtCore.Qt.Window)
review.paintRequested.connect(self.print)
review.exec_()