当前位置: 首页>>代码示例>>Python>>正文


Python QtPrintSupport.QPrintDialog方法代码示例

本文整理汇总了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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:24,代码来源:browsertab.py

示例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() 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:26,代码来源:printer.py

示例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() 
开发者ID:morten1982,项目名称:crossCobra,代码行数:18,代码来源:crosscobra.py

示例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())) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:7,代码来源:webpage.py

示例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()) 
开发者ID:goldsborough,项目名称:Writer-Tutorial,代码行数:9,代码来源:part-1.py

示例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


注:本文中的PyQt5.QtPrintSupport.QPrintDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。