當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。