def askPrinter():
    printer = QPrinter()
    select = QPrintDialog(printer)
    if select.exec_():
        return printer
    else:
        return None
Пример #2
0
 def printDocument(self):
     dialog = QPrintDialog()
     if not dialog.exec_():
         return
     self.printer = dialog.printer()
     self.imprimir(self.printer)
     self.document.load(self.editmodel)
Пример #3
0
    def printFile(self): # Needs some work...
        printDialog = QPrintDialog(self.printer, py_de)
        if printDialog.exec_() == QDialog.Accepted:
            margin = 10
            pageNum = 1
            yPos = 0
            printJob = QPainter()
            printJob.begin(self.printer)
            printJob.setFont(self.font)
            fm = printJob.fontMetrics()

            for i in range(self.textEdit.lines()):
                if margin + yPos > self.printer.height() - margin:
                    pageNum += 1
                    self.printer.newPage()
                    yPos = 0
                printJob.drawText(margin,               # X
                                  margin + yPos,        # Y
                                  self.printer.width(), # Width
                                  self.printer.height(),# Height
                                  QtCore.Qt.AlignTop,       # Alignment
                                  self.textEdit.text(i - 1)# The text to print
                                  )
                yPos += fm.lineSpacing()
            printJob.end
Пример #4
0
    def showDialog(self, parent):
        dialog = QPrintDialog(self.printer, parent)
        if dialog.exec_() != QPrintDialog.Accepted:
            return False

        self._init_painter()
        return True
Пример #5
0
 def _print_report(self):
     printer = QPrinter()
     print_dialog = QPrintDialog(printer, self)
     print_dialog.setWindowTitle("Print report")
     if print_dialog.exec_() != QDialog.Accepted:
         return
     self.report_view.print_(printer)
Пример #6
0
 def printNote(self):
     printer = QPrinter(QPrinter.HighResolution)
     printer.setCreator(__appname__ + ' ' + __version__)
     printer.setDocName(self.notesTree.currentItem().text(0))
     printdialog = QPrintDialog(printer, self)
     if printdialog.exec() == QDialog.Accepted:
         self.notesView.print_(printer)
Пример #7
0
 def _print_report(self):
     printer = QPrinter()
     print_dialog = QPrintDialog(printer, self)
     print_dialog.setWindowTitle("Print report")
     if print_dialog.exec_() != QDialog.Accepted:
         return
     self.report_view.print_(printer)
Пример #8
0
 def printDocument(self):
     dialog = QPrintDialog()
     if not dialog.exec_():
         return
     self.printer = dialog.printer()    
     self.imprimir(self.printer)
     self.document.load(self.editmodel)
Пример #9
0
 def printNote(self):
     printer = QPrinter(QPrinter.HighResolution)
     printer.setCreator(__appname__ + ' ' + __version__)
     printer.setDocName(self.notesTree.currentItem().text(0))
     printdialog = QPrintDialog(printer, self)
     if printdialog.exec() == QDialog.Accepted:
         self.notesView.print_(printer)
Пример #10
0
 def printContents(self, printer=None):
     if not printer:
         printer = QPrinter()
     dialog = QPrintDialog(printer, self)
     dialog.setWindowTitle(QCoreApplication.translate("QPyShell", "Print Document"))
     if dialog.exec_() != QDialog.Accepted:
         return
     self.outputBrowser.document().print_(printer)
Пример #11
0
 def printWindow(self, printer=None):
     if not printer:
         printer = QPrinter()
     dialog = QPrintDialog(printer, self)
     dialog.setWindowTitle(QCoreApplication.translate('LogWindow', 'Print Document'))
     if dialog.exec_() != QDialog.Accepted:
         return
     self.logView.TextArea.document().print_(printer)
Пример #12
0
 def _onShortcutPrint(self):
     """Ctrl+P handler.
     Show dialog, print file
     """
     dialog = QPrintDialog(self)
     if dialog.exec_() == QDialog.Accepted:
         printer = dialog.printer()
         self.print_(printer)
Пример #13
0
 def _onShortcutPrint(self):
     """Ctrl+P handler.
     Show dialog, print file
     """
     dialog = QPrintDialog(self)
     if dialog.exec_() == QDialog.Accepted:
         printer = dialog.printer()
         self.print_(printer)
Пример #14
0
 def _print(self):
     dialog = QPrintDialog(self)
     if dialog.exec_() != QPrintDialog.Accepted:
         return
     printer = dialog.printer()
     currentView = self.mainView.currentWidget()
     viewPrinter = ViewPrinter(printer, currentView)
     currentView.fitViewsForPrint(viewPrinter)
     viewPrinter.render()
Пример #15
0
 def print_(self):
     dialog = QPrintDialog(self.printer)
     if dialog.exec_():
         painter = QPainter(self.printer)
         painter.setRenderHint(QPainter.Antialiasing)
         painter.setRenderHint(QPainter.TextAntialiasing)
         self.scene.clearSelection()
         #self.removeBorders()
         self.scene.render(painter)
Пример #16
0
 def printWindow(self, printer=None):
     if not printer:
         printer = QPrinter()
     printer.setFullPage(True)
     printer.setPageSize(QPrinter.A4)
     dialog = QPrintDialog(printer, self)
     dialog.setWindowTitle(QCoreApplication.translate('QwtPlot', 'Print Document'))
     if dialog.exec_() != QDialog.Accepted:
         return
     self.plot.print_(printer, QwtPlotPrintFilter())
Пример #17
0
def printc(tedit,titulo="Reporte",orientacion=0,margen=[5,10,5,10,0]):
  printer=QtGui.QPrinter(QPrinter.HighResolution)
  printer.setOrientation(orientacion)
  printer.setPaperSize(QtGui.QPrinter.Letter)
  printer.setPageMargins(*margen)
  printer.setOutputFormat(QPrinter.PdfFormat)
  printer.setOutputFileName(titulo)
  prev=QPrintDialog(printer)
  if prev.exec_()==QDialog.Accepted:
      tedit.print_(printer)
Пример #18
0
    def slot_canvasPrint(self):
        self.scene.clearSelection()
        self.fExportPrinter = QPrinter()
        dialog = QPrintDialog(self.fExportPrinter, self)

        if dialog.exec_():
            painter = QPainter(self.fExportPrinter)
            painter.setRenderHint(QPainter.Antialiasing)
            painter.setRenderHint(QPainter.TextAntialiasing)
            self.scene.render(painter)
Пример #19
0
def canvas_print(self_):
    self_.scene.clearSelection()
    self_.m_export_printer = QPrinter()
    dialog = QPrintDialog(self_.m_export_printer, self_)

    if dialog.exec_():
        painter = QPainter(self_.m_export_printer)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.TextAntialiasing)
        self_.scene.render(painter)
Пример #20
0
    def print_photo(self):
        print_dialog = QPrintDialog(self._printer,self)

        if print_dialog.exec_() == QDialog.Accepted:
            painter = QPainter(self._printer)
            rect = painter.viewport()
            size = self._lbl_photo.pixmap().size()
            size.scale(rect.size(), Qt.KeepAspectRatio)
            painter.setViewport(rect.x(), rect.y(), size.width(), size.height())
            painter.setWindow(self._lbl_photo.pixmap().rect())
            painter.drawPixmap(0, 0, self._lbl_photo.pixmap())
Пример #21
0
 def print_webpage(self):
     """
     Callback for the print action.  Should show a print dialog and print the webpage to the printer.
     """
     printer = QPrinter()
     print_dialog = QPrintDialog(printer, self)
     print_dialog.setWindowTitle("Print Page")
     if print_dialog.exec_() == QDialog.Accepted:
         self.print_(printer)
     else:
         return False
Пример #22
0
    def open_print_dialog(self):
        """ This member function calls print routine. """

        aPrinter = QPrinter(QPrinter.HighResolution)
        printDialog = QPrintDialog(aPrinter)

        # need this to make sure we take away focus from
        # any currently selected legend items
        self.canvas.clearFocus()

        if printDialog.exec_() == QDialog.Accepted:
            io.printer(self.canvas, aPrinter)
Пример #23
0
    def open_print_dialog(self):
        """ This member function calls print routine. """

        aPrinter = QPrinter(QPrinter.HighResolution)
        printDialog = QPrintDialog(aPrinter)

        # need this to make sure we take away focus from
        # any currently selected legend items
        self.canvas.clearFocus()

        if printDialog.exec_() == QDialog.Accepted:
            io.printer(self.canvas, aPrinter)
Пример #24
0
    def slot_canvasPrint(self):
        self.scene.clearSelection()
        self.fExportPrinter = QPrinter()
        dialog = QPrintDialog(self.fExportPrinter, self)

        if dialog.exec_():
            painter = QPainter(self.fExportPrinter)
            painter.save()
            painter.setRenderHint(QPainter.Antialiasing, True)
            painter.setRenderHint(QPainter.TextAntialiasing, True)
            self.scene.render(painter)
            painter.restore()
Пример #25
0
    def printDocument1(self):
        html = u""

        date = QDate.currentDate().toString(self.DATE_FORMAT)

        address = Qt.escape("Bario francisco mesa").replace(",", "<br>")
        contact = Qt.escape("Luis Mejia")
        balance = 5000
        html += ("<p align=right><img src=':/logo.png'></p>"
                 "<p> align = right>Greasy hands ltd."
                 "<br>New Lombard Street"
                 "<br>London<br>WC13 4PX<br>%s</p>"
                 "<p>%s</p><p>Dear %s, </p>"
                 "<p>The balance of your account is %s.") % (
                     date, address, contact, QString("$ %L1").arg(
                         float(balance), 0, "f", 2))

        if balance < 0:
            html += (
                "<p><font color =red><b> Please remit the amount owing immediately.</b></font>"
            )
        else:
            html += "We are delighted to have done business with you."

        html += (
            "</p><p>&nbsp;</p><p>"
            "<table border=1 cellpadding=2 cellspacing=2><tr><td colspan=3>Transaction</td></tr>"
        )
        transactions = [(QDate.currentDate(), 500), (QDate.currentDate(), 500),
                        (QDate.currentDate(), -500),
                        (QDate.currentDate(), 500)]
        for date, amount in transactions:
            color, status = "black", "Credit"
            if amount < 0:
                color, status = "red", "Debid"

            html += (
                "<tr>"
                "<td align= right>%s</td>"
                "<td>%s</td><td align=right><font color=%s>%s</font></td></tr>"
                % (date.toString(self.DATE_FORMAT), status, color,
                   QString("$ %L1").arg(float(abs(amount)), 0, "f", 2)))

        html += ("</table></p><p style='page-break-after=always;'>"
                 "We hope to continue doing business with you</p>")

        pdialog = QPrintDialog()
        if pdialog.exec_() == QDialog.Accepted:
            printer = pdialog.printer()
            document = QTextDocument()
            document.setHtml(html)
            document.print_(printer)
Пример #26
0
 def _print_file(self):
     self.printer = QPrinter(QPrinter.HighResolution)
     self.printer.setPageSize(QPrinter.A4)
     if self._central.obtain_editor().path:
         fileName = manage_files.get_basename(self._central.obtain_editor().path)
         fileName = fileName[:fileName.rfind('.')] + '.pdf'
     else:
         fileName = 'newDocument.pdf'
     self.printer.setOutputFileName(fileName)
     dialog = QPrintDialog(self.printer, self)
     if dialog.exec_():
         self.printer.setDocName(manage_files.get_basename(self._central.obtain_editor().path))
         self._central.obtain_editor().document().print_(self.printer)
Пример #27
0
 def on_actionPrint_triggered(self):
     if self.printer is None:
         self.printer = QPrinter(QPrinter.HighResolution)
         self.printer.setPageSize(QPrinter.Letter)
     form = QPrintDialog(self.printer, self)
     if form.exec_():
         painter = QPainter(self.printer)
         rect = painter.viewport()
         size = self.image.size()
         size.scale(rect.size(), Qt.KeepAspectRatio)
         painter.setViewport(rect.x(), rect.y(), size.width(),
                             size.height())
         painter.drawImage(0, 0, self.image)
Пример #28
0
    def on_webview_loadFinished(self, status):
        if self.printProgressBar.isVisible():
            self.printProgressBar.hide()
        if not status:
            QMessageBox.critical(self, qApp.organizationName(), "El reporte no se pudo cargar")
            logging.error("No se pudo cargar el reporte")

        self.loaded = True

        printdialog = QPrintDialog(self.printer, self)
        if printdialog.exec_() == QDialog.Accepted:
            self.webview.print_(self.printer)

        del self.webview
 def printWindow(self, printer=None):
     if not printer:
         printer = QPrinter()
     printer.setFullPage(True)
     printer.setPageSize(QPrinter.A4)
     dialog = QPrintDialog(printer, self)
     dialog.setWindowTitle(QCoreApplication.translate('Graphics', 'Print Document'))
     if dialog.exec_() != QDialog.Accepted:
         return
     # FIXME: on windows the resolutions seems to be very low, why?
     #printer.setResolution(600)
     painter = QPainter(printer)
     painter.setRenderHint(QPainter.Antialiasing)
     self.graphicsView.scene().render(painter)
Пример #30
0
    def savePrinter(self):
        """
        Save to printer
        """
        printer = QPrinter()
        dialog = QPrintDialog(printer, self)
        dialog.setWindowTitle("Print")

        if dialog.exec_() != QDialog.Accepted:
            return

        doc = QTextDocument()
        doc.setPlainText(self.txtEdit.text())
        doc.print_(printer)
Пример #31
0
 def printSource(self):
     cursor = self.textCursor()
     try:
         printer = self._sourcePrinter
     except AttributeError:
         printer = self._sourcePrinter = QPrinter()
     else:
         printer.setCopyCount(1)
     dlg = QPrintDialog(printer, self)
     dlg.setWindowTitle(app.caption(_("dialog title", "Print Source")))
     options = QAbstractPrintDialog.PrintToFile | QAbstractPrintDialog.PrintShowPageSize
     if cursor.hasSelection():
         options |= QAbstractPrintDialog.PrintSelection
     dlg.setOptions(options)
     if dlg.exec_():
         if dlg.printRange() != QAbstractPrintDialog.Selection:
             cursor.clearSelection()
         number_lines = QSettings().value("source_export/number_lines",
                                          False, bool)
         doc = highlighter.html_copy(cursor, 'printer', number_lines)
         doc.setMetaInformation(QTextDocument.DocumentTitle,
                                self.currentDocument().url().toString())
         font = doc.defaultFont()
         font.setPointSizeF(font.pointSizeF() * 0.8)
         doc.setDefaultFont(font)
         doc.print_(printer)
Пример #32
0
    def printDocument1(self):
        html = u""

        date = QDate.currentDate().toString(self.DATE_FORMAT)
        
        address = Qt.escape("Bario francisco mesa").replace(",","<br>")
        contact = Qt.escape("Luis Mejia")
        balance = 5000
        html += ("<p align=right><img src=':/logo.png'></p>"
                 "<p> align = right>Greasy hands ltd."
                 "<br>New Lombard Street"
                 "<br>London<br>WC13 4PX<br>%s</p>"
                 "<p>%s</p><p>Dear %s, </p>"
                 "<p>The balance of your account is %s.")% (
                   date, address, contact, QString("$ %L1").arg(float(balance),0,"f",2))
                 
        if balance <0 :
            html += ("<p><font color =red><b> Please remit the amount owing immediately.</b></font>")
        else:
            html += "We are delighted to have done business with you."
        
        html += ("</p><p>&nbsp;</p><p>"
                "<table border=1 cellpadding=2 cellspacing=2><tr><td colspan=3>Transaction</td></tr>")
        transactions = [
                        (QDate.currentDate(),500),
                        (QDate.currentDate(),500),
                        (QDate.currentDate(),-500),
                        (QDate.currentDate(),500)
                        ]
        for date, amount in transactions:
            color, status = "black", "Credit"
            if amount <0:
                color, status = "red", "Debid"
            
            html += ("<tr>"
                        "<td align= right>%s</td>"
                        "<td>%s</td><td align=right><font color=%s>%s</font></td></tr>" % (
                        date.toString(self.DATE_FORMAT), status,color, QString("$ %L1").arg(float(abs(amount)), 0, "f",2)))
            
        html += ("</table></p><p style='page-break-after=always;'>"
                 "We hope to continue doing business with you</p>")
                 
        
        pdialog = QPrintDialog() 
        if pdialog.exec_() == QDialog.Accepted:
            printer = pdialog.printer()
            document = QTextDocument()
            document.setHtml(html)
            document.print_(printer)
Пример #33
0
 def on_stampa_triggered(self, checked=None):
     """Slot launched when the user click on the "stampa" button"""
     if checked is None:
         return
     printer = QPrinter()
     print_dialog = QPrintDialog(printer, self)
     if print_dialog.exec_() == QDialog.Accepted:
         printer.setOrientation(QPrinter.Landscape)
         painter = QPainter()
         painter.begin(printer)
         geometry = self.ui_calendar.Table.geometry()
         self.ui_calendar.Table.setGeometry(printer.pageRect())
         self.ui_calendar.Table.render(painter)
         self.ui_calendar.Table.setGeometry(geometry)
         painter.end()
Пример #34
0
    def printdoc(self):
        """
        Prints the document in the view
        """
        printer = QPrinter()

        setup = QPageSetupDialog(printer)
        setup.setWindowTitle("Print - Page Settings")

        if setup.exec_() == QDialog.Accepted:
            dialog = QPrintDialog(printer, self)
            dialog.setWindowTitle("Print Document")

            if dialog.exec_() == QDialog.Accepted:
                self.ui.webviewResult.print_(printer)
Пример #35
0
	def printCharacter(self):
		"""
		Druckt den angezeigten Charakter aus.
		"""

		printer = QPrinter(QPrinter.PrinterResolution)
		printDialog = QPrintDialog( printer, self )

		if ( printDialog.exec_() == QDialog.Accepted ):
			drawSheet = RenderSheet( self.__storage, self.__character, printer, self )

			try:
				drawSheet.createSheets()
			except ErrSpeciesNotExisting as e:
				MessageBox.exception( self, e.message, e.description )
Пример #36
0
    def printBill(self):
        self.saveTab() #save before printing so that changes will be added to print
        
        html = self.creator.makePrintfile(self.item)
        document = QWebView()
        document.setHtml(html)

        printer = QPrinter()
        
        printer.setOutputFileName(getBillPath() + str(datetime.datetime.now())[0:-7] + '_' + str(self.item.id) + '.pdf')
        
        printpreview = QPrintDialog(printer, self)
        printpreview.exec()
        
        document.print(printer)
Пример #37
0
 def filePrint(self):
     if self.image.isNull():
         return
     if self.printer is None:
         self.printer = QPrinter(QPrinter.HighResolution)
         self.printer.setPageSize(QPrinter.Letter)
     form = QPrintDialog(self.printer, self)
     if form.exec_():
         painter = QPainter(self.printer)
         rect = painter.viewport()
         size = self.image.size()
         size.scale(rect.size(), Qt.KeepAspectRatio)
         painter.setViewport(rect.x(), rect.y(), size.width(),
                             size.height())
         painter.drawImage(0, 0, self.image)
Пример #38
0
    def printCharacter(self):
        """
		Druckt den angezeigten Charakter aus.
		"""

        printer = QPrinter(QPrinter.PrinterResolution)
        printDialog = QPrintDialog(printer, self)

        if (printDialog.exec_() == QDialog.Accepted):
            drawSheet = RenderSheet(self.__storage, self.__character, printer,
                                    self)

            try:
                drawSheet.createSheets()
            except ErrSpeciesNotExisting as e:
                MessageBox.exception(self, e.message, e.description)
Пример #39
0
    def savePrinter(self):
        """
        Save to printer
        """
        printer = QPrinter()
        dialog = QPrintDialog(printer, self)
        dialog.setWindowTitle("Print")

        if dialog.exec_() != QDialog.Accepted:
            return

        if QtHelper.IS_QT5:  # new in v18
            self.fileName = printer
            self.txtEdit.page().toHtml(self.__toPrinter)
        else:
            self.txtEdit.print_(printer)
Пример #40
0
    def imprimir(self):
      	printer=QPrinter(QPrinter.HighResolution)
	printer.setPaperSize(QPrinter.Letter)   
	printer.setOutputFormat(QPrinter.PdfFormat)
	ruta=os.path.join(self.parent.cfg.get("factura", "ruta"),'Factura-'+str(self.num)+'.pdf')
	printer.setOutputFileName(ruta)
	prev=QPrintDialog(printer,self.padre)
	if prev.exec_()==QDialog.Accepted:
	    paint=QPainter()
	    paint.begin(printer)
	    self.escena.render(paint)
	    paint.end()
	    print "Imprimiendo..."
	    
	if sys.platform == 'linux2':
	    os.system("gnome-open '%s' "%ruta)
	elif sys.platform == 'win32':
	    os.system("start '%s'"%ruta)
Пример #41
0
    def printFile(self):
        """Print file
        """
        printer = QsciPrinter()
        
        # set wrapmode
        printer.setWrapMode(QsciScintilla.WrapWord)

        dialog = QPrintDialog (printer)
        
        if dialog.exec_() == dialog.Accepted:
            if  dialog.printRange() == dialog.Selection:
                f, unused, t, unused1 = self.qscintilla.getSelection()
            else:
                f = -1
                t = -1

            printer.printRange(self.qscintilla, f, t)
Пример #42
0
    def savePrinter(self):
        """
        Save to printer
        """
        printer = QPrinter()
        dialog = QPrintDialog(printer, self)
        dialog.setWindowTitle("Print")

        if dialog.exec_() != QDialog.Accepted:
            return

        if QtHelper.IS_QT5: # new in v18
            self.fileName = printer
            self.txtEdit.page().toHtml(self.__toPrinter)
        else:
            frame = self.txtEdit.page().mainFrame()
        
            doc = QTextDocument()
            doc.setPlainText( frame.toPlainText() )
            doc.print_(printer)
Пример #43
0
 def print_(self):
     printer = QPrinter()
     dlg = QPrintDialog(printer, self)
     dlg.setWindowTitle(app.caption(_("Print")))
     options = (QAbstractPrintDialog.PrintToFile
                | QAbstractPrintDialog.PrintShowPageSize
                | QAbstractPrintDialog.PrintPageRange)
     if self.browser.textCursor().hasSelection():
         options |= QAbstractPrintDialog.PrintSelection
     dlg.setOptions(options)
     if dlg.exec_():
         self.browser.print_(printer)
Пример #44
0
 def Printout(self):
     # Version utilisant QSvg
     # Fixme: l'alpha n'est pas bien rendu
     # (le fond des polygones est absent)
     # Le fond est bien présent après export avec matplotlib pourtant.
     printer = QPrinter(QPrinter.HighResolution)
     dialog = QPrintDialog(printer, self)
     dialog.setOption(QPrintDialog.PrintPageRange, False)
     dialog.setOption(QPrintDialog.PrintToFile, True)
     dialog.setOption(QPrintDialog.PrintShowPageSize, True)
     dialog.setWindowTitle("Imprimer le document")
     if (dialog.exec_() == QDialog.Accepted):
         painter = QPainter(printer)
         try:
             output = StringIO()
             self.onglet_actuel.canvas.exporter(output, format='svg')
             svg = QSvgRenderer(QByteArray(output.getvalue()), self)
             size = svg.defaultSize()
             size.scale(painter.viewport().size(), Qt.KeepAspectRatio)
             rect = QRectF(0, 0, size.width(), size.height())
             svg.render(painter, rect)
         finally:
             painter.end()
Пример #45
0
 def outPrint(
         self, iface, wdg, mdl,
         library):  # Postscript file rendering doesn't work properly yet.
     for i in range(0, mdl.rowCount()):
         if mdl.item(i, 0).data(Qt.CheckStateRole):
             name = str(mdl.item(i, 2).data(Qt.EditRole))
             #return
     fileName = QFileDialog.getSaveFileName(iface.mainWindow(), "Save As",
                                            "Profile of " + name + ".ps",
                                            "PostScript Format (*.ps)")
     if fileName:
         if library == "Qwt5" and has_qwt:
             printer = QPrinter()
             printer.setCreator("QGIS Profile Plugin")
             printer.setDocName("QGIS Profile")
             printer.setOutputFileName(fileName)
             printer.setColorMode(QPrinter.Color)
             printer.setOrientation(QPrinter.Portrait)
             dialog = QPrintDialog(printer)
             if dialog.exec_():
                 wdg.plotWdg.print_(printer)
         elif library == "Matplotlib" and has_mpl:
             wdg.plotWdg.figure.savefig(str(fileName))
Пример #46
0
 def print_on_paper(self):
     """Print the document with a printer."""
     
     printer = Qsci.QsciPrinter()
     print_dialog = QPrintDialog(printer)
     print_dialog.setWindowTitle(self.tr("Print Document"))
     print_dialog.addEnabledOption(QPrintDialog.PrintSelection)
     if print_dialog.exec_() == QPrintDialog.Accepted:
         printer.printRange(self)
Пример #47
0
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"""
    #TODO: Make that the option it's taken from settings. maybe
    #this should be a class to manage all cases?

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)
    #PRINT PREVIEW OPTIONS
    #TODO: the follow imp. dipatch an error on execution time we need to review
    #if the error belongs to qt
    #    preview = QPrintPreviewDialog(printer)
    #    preview.paintRequested[QPrinter].connect(printFunction)
    #    preview.exec_()
    dialog = QPrintDialog(printer)
    if dialog.exec_():
        printFunction(printer)
Пример #48
0
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"""
    #TODO: Make that the option it's taken from settings. maybe
    #this should be a class to manage all cases?

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)
#PRINT PREVIEW OPTIONS
#TODO: the follow imp. dipatch an error on execution time we need to review
#if the error belongs to qt
#    preview = QPrintPreviewDialog(printer)
#    preview.paintRequested[QPrinter].connect(printFunction)
#    preview.exec_()
    dialog = QPrintDialog(printer)
    if dialog.exec_():
        printFunction(printer)
Пример #49
0
 def slotPrint(self):
     printer = QPrinter()
     dlg = QPrintDialog(printer, self)
     dlg.setWindowTitle(app.caption(_("Print")))
     if dlg.exec_():
         self.webview.print_(printer)
Пример #50
0
 def _onPrint(self):
     printer = QPrinter()
     dialog = QPrintDialog(printer, self)
     if dialog.exec_() != QDialog.Accepted:
         return
     self.page.mainFrame().print_(printer)
Пример #51
0
 def showprint(self):
     self._printbox = QPrintDialog(self)
     if self._printbox.exec_() == QDialog.Accepted:
         self.printout()
Пример #52
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(QMainWindow, self).__init__()
        self._TITLE = 'Equilibrium Simulator 2015'
        self.setGeometry(0, 22, 1200, 400)
        self.setWindowTitle(self._TITLE)
        self._showorhide = "Show "
        self._printbox = None
        self._printer = QPrinter()
        self._Squares = []

        # Menu bar
        self.MenuBar = self.menuBar()
        self.filemenu = self.MenuBar.addMenu('File')
        self.optionsmenu = self.MenuBar.addMenu('Options')
        self.aboutmenu = self.MenuBar.addMenu('About')

        # File - New
        newfile = QAction(QIcon('exit.png'), 'New', self)
        newfile.setStatusTip('Create a new file')
        self.filemenu.addAction(newfile)
        newfile.triggered.connect(self.shownew)

        # File - Open
        openfile = QAction(QIcon('open.png'), 'Open', self)
        openfile.setStatusTip('Open a file')
        self.filemenu.addAction(openfile)
        openfile.triggered.connect(self.showopen)

        # File - Save
        savefile = QAction(QIcon('save.png'), 'Save', self)
        savefile.setStatusTip('Save the current file')
        self.filemenu.addAction(savefile)
        savefile.triggered.connect(self.save)

        # File - Save as
        saveasfile = QAction(QIcon('save.png'), 'Save as', self)
        saveasfile.setStatusTip('Save the current file as a different file')
        self.filemenu.addAction(saveasfile)
        saveasfile.triggered.connect(self.showsaveas)

        # File - Print
        printfile = QAction(QIcon('save.png'), 'Print', self)
        printfile.setStatusTip('Print the displayed reactions')
        self.filemenu.addAction(printfile)
        printfile.triggered.connect(self.showprint)

        # File - Exit
        exitaction = QAction(QIcon('exit.png'), '&Exit', self)
        exitaction.setStatusTip('Exit the program')
        exitaction.triggered.connect(qApp.quit)
        self.filemenu.addAction(exitaction)

        # Options - Edit Conditions
        editconds = QAction(QIcon('exit.png'), 'Edit Conditions', self)
        editconds.setStatusTip('Edit the conditions of the current reaction')
        editconds.triggered.connect(self.editcd)
        self.optionsmenu.addAction(editconds)

        # About - Version
        version = QAction(QIcon('exit.png'), 'Version 1.1', self)
        version.setStatusTip('The version of this program you are using')

        # Widget of editable reactions
        self._ReactionsWindow = ReactionWidget()
        self._ReactionsWindow.setGeometry(0, 20, 600, 380)
        self._ReactionsWindow.setParent(self)

        # Widget of non-editable reaction, for comparison
        self._ComparingProfile = ReactionProfile(
            self._ReactionsWindow.GetCurrentReaction(), True)
        self._ComparingProfile.setGeometry(600, 40, 600, 380)
        self._ComparingProfile.setParent(self)
        self.aboutmenu.addAction(version)
        self.show()

    # You should call the shownew(), showopen() etc. methods,
    # not the new(), open() etc. methods, as a) they do not provide user options;
    # b) it may lead to errors; c) the showing methods call them anyway
    def editcd(self):
        self._ReactionsWindow.EditReaction()

    def showopen(self):
        fileaddress = QFileDialog.getOpenFileName(self, "Open...", "",
                                                  "Simulator Files (*.rctn)")
        if fileaddress != "":
            self.open(fileaddress)
            self.setWindowTitle(fileaddress + " - " + self._TITLE)

    def open(self, fileaddress):
        openfrom = open(fileaddress, "rb")
        loadedfile = pickle.load(openfrom)
        openfrom.close()
        file = open("last.ptr", "w")
        file.write(fileaddress)
        file.close()
        self._ReactionsWindow.SetOpenReactionFile(loadedfile)
        self.setWindowTitle(fileaddress + " - " + self._TITLE)

    def save(self):
        self._ReactionsWindow.save()

    def showsaveas(self):
        self._ReactionsWindow.showsaveas()

    def shownew(self):
        self._newfilebox = QMessageBox()
        self._newfilebox.setWindowTitle("Save?")
        self._newfilebox.setText(
            "Would you like to save this file before opening a new one?")
        self._newfilebox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        self._newfilebox.setDefaultButton(QMessageBox.Yes)
        if self._newfilebox.exec_() == QMessageBox.Yes:
            file = open("last.ptr", "w")
            file.write("")
            file.close()
            self.save()
        self.setWindowTitle(self._TITLE)
        self._ReactionsWindow.SetOpenReactionFile(ReactionFile())

    def showprint(self):
        self._printbox = QPrintDialog(self)
        if self._printbox.exec_() == QDialog.Accepted:
            self.printout()

    def printout(self):
        # Page width, page height, widget width
        pw = self._printer.pageRect().width()
        ph = self._printer.pageRect().height()
        ww = self._ComparingProfile.width()
        painter = QPainter(self._printer)
        scale = (ww / pw) * 1.5
        painter.scale(scale, scale)
        self._ReactionsWindow.currentWidget().render(painter)
        painter.translate(0, ph / 2)
        self._ComparingProfile.render(painter)
        painter.translate(pw * 0.6, -ph / 2)
        painter.scale(0.8, 0.8)
        self._ReactionsWindow.currentWidget().PrintGraph(
            painter, "Concentration")
        painter.translate(0, ph * 0.25)
        self._ReactionsWindow.currentWidget().PrintGraph(painter, "Rate")
        painter.translate(0, ph * 0.4)
        self._ComparingProfile.PrintGraph(painter, "Concentration")
        painter.translate(0, ph * 0.25)
        self._ComparingProfile.PrintGraph(painter, "Rate")
        painter.end()

    # GETTERS AND SETTERS
    def GetWindowTitle(self):
        return self._TITLE

    def SetComparingReaction(self, reaction):
        self._ComparingProfile.SetReaction(reaction)
        self._ComparingProfile.update()

    def GetComparingReaction(self):
        return self._ComparingProfile.GetReaction()
Пример #53
0
 def handlePrint(self):
     dialog = QPrintDialog()
     if dialog.exec_() == QDialog.Accepted:
         self.handlePaintRequest(dialog.printer())
Пример #54
0
    def onPlotButton(self):
        """ Batch plots selected geometry items using the selected template and scale.
        """
        # check if one layer is selected
        if self.ui.LayersComboBox.currentIndex() == -1:
            QMessageBox.warning(self, tr("Warning"), tr("Select a layer!"))
            self.ui.LayersComboBox.setFocus()
            return
        # check if one composition template is selected
        if self.ui.TemplateList.selectedItems() == []:
            QMessageBox.warning(self, tr("Warning"),
                                tr("Select a composer template!"))
            self.ui.TemplateList.setFocus()
            return
        template_filename = QDir(self.templatepath).absoluteFilePath(
            self.ui.TemplateList.currentItem().text())

        # get the scale
        if self.ui.ScaleCombo.currentText() == "<extent>":
            scale = -1
        else:
            try:
                scale = int(self.ui.ScaleCombo.currentText())
            except (ValueError):
                QMessageBox.warning(
                    self, tr("Warning"),
                    tr("Scale must be a positive integer value!"))
                self.ui.ScaleCombo.setFocus()
                return
            if scale <= 0:
                QMessageBox.warning(
                    self, tr("Warning"),
                    tr("Scale must be a positive integer value!"))
                self.ui.ScaleCombo.setFocus()
                return

        # get composer name
        composer_name = self.ui.ComposerEdit.text()

        #check if there are selected items on polygon layers
        if self.batch_plotting:
            selected_layer = self.ui.LayersComboBox.itemData(
                self.ui.LayersComboBox.currentIndex())
            selected_polygons = get_features(selected_layer.name(),
                                             QGis.Polygon, True)
            if selected_polygons is None:
                QMessageBox.warning(
                    self, tr("Warning"),
                    tr("Select at least one polygon on layer '%s'!" %
                       selected_layer.name()))
                return

        # check output setting
        if self.ui.OutputTab.currentIndex() == 0:  # to PDF
            if not self.ui.SingleFileCheckbox.checkState():
                if len(self.ui.OutputPDFEdit.text()) == 0:
                    res = QMessageBox.warning(
                        self, tr("Warning"),
                        tr("The filename pattern is empty. A default one will be used."
                           ), QMessageBox.Ok | QMessageBox.Cancel,
                        QMessageBox.Ok)
                    if res == QMessageBox.Cancel:
                        return
                    self.ui.OutputPDFEdit.setText(
                        QgsAtlasComposition(None).filenamePattern())
        elif self.ui.OutputTab.currentIndex() == 1:  # to Printer
            # no need for checking
            pass
        elif self.ui.OutputTab.currentIndex() == 2:  # to Composer View
            # no need for checking yet
            pass

        # get map renderer of map canvas
        renderer = self.iface.mapCanvas().mapRenderer()
        self.composition = QgsComposition(renderer)

        # if plot to Composer View the composition must be set
        # before loading the template
        # otherwise composer's item properties doesn't appear
        if self.ui.OutputTab.currentIndex() == 2:  # to Composer View
            if len(composer_name) == 0:
                composer = self.iface.createNewComposer()
            else:
                composer = self.iface.createNewComposer(composer_name)
            composer.setComposition(self.composition)

        # read template file and add to composition
        template_file = QFile(template_filename)
        template_file.open(QIODevice.ReadOnly | QIODevice.Text)
        template_content = template_file.readAll()
        template_file.close()
        document = QDomDocument()
        document.setContent(template_content)
        self.composition.loadFromTemplate(document)

        # if batch_plotting is True create an atlas composition
        if self.batch_plotting:
            # get composer map item and set new scale and the grid
            cmap = self.composition.getComposerMapById(0)
            cmap.setNewScale(scale)
            cmap.setGridIntervalX(scale / 10)
            cmap.setGridIntervalY(scale / 10)
            cmap.setAtlasDriven(True)
            cmap.setAtlasScalingMode(QgsComposerMap.Fixed)

            # set atlas composition parameters
            atlas = self.composition.atlasComposition()
            atlas.setEnabled(True)
            atlas.setCoverageLayer(selected_layer)
            atlas.setHideCoverage(False)
            atlas.setFilenamePattern(self.ui.OutputPDFEdit.text())
            atlas.setSingleFile(self.ui.SingleFileCheckbox.checkState())
            atlas.setSortFeatures(False)
            atlas.setFilterFeatures(True)
            selected_ids = [f.id() for f in selected_layer.selectedFeatures()]
            filter_id_string = ','.join([str(sid) for sid in selected_ids])
            atlas.setFeatureFilter("$id in (" + filter_id_string + ")")

            # print the complete atlas composition
            if self.ui.OutputTab.currentIndex() == 0:  # to PDF
                self.composition.setAtlasMode(QgsComposition.ExportAtlas)

                if self.pdfpath == "":
                    self.pdfpath = QgsProject.instance().homePath().encode(
                        sys.getfilesystemencoding())

                if self.ui.SingleFileCheckbox.checkState():
                    #print to single pdf (multi-page)
                    outputFileName = QDir(
                        self.pdfpath).absoluteFilePath("qgis.pdf")
                    outputFileName = QFileDialog.getSaveFileName(
                        self, tr("Choose a file name to save the map as"),
                        outputFileName,
                        tr("PDF Format") + " (*.pdf *.PDF)")
                    if not outputFileName:
                        return
                    if not outputFileName.lower().endswith(".pdf"):
                        outputFileName += ".pdf"
                    self.pdfpath = QDir(outputFileName).absolutePath()
                else:
                    #print to more pdf
                    outputDir = QFileDialog.getExistingDirectory(
                        self, tr("Directory where to save PDF files"),
                        self.pdfpath, QFileDialog.ShowDirsOnly)
                    if not outputDir:
                        return
                    # test directory (if it exists and is writable)
                    if not QDir(outputDir).exists() or not QFileInfo(
                            outputDir).isWritable():
                        QMessageBox.warning(
                            self, tr("Unable to write into the directory"),
                            tr("The given output directory is not writable. Cancelling."
                               ))
                        return
                    self.pdfpath = outputDir

                printer = QPrinter()
                painter = QPainter()
                if not len(atlas.featureFilterErrorString()) == 0:
                    QMessageBox.warning(
                        self, tr("Atlas processing error"),
                        tr("Feature filter parser error: %s" %
                           atlas.featureFilterErrorString()))
                    return

                atlas.beginRender()

                if self.ui.SingleFileCheckbox.checkState():
                    #prepare for first feature, so that we know paper size to begin with
                    atlas.prepareForFeature(0)
                    self.composition.beginPrintAsPDF(printer, outputFileName)
                    # set the correct resolution
                    self.composition.beginPrint(printer)
                    printReady = painter.begin(printer)
                    if not printReady:
                        QMessageBox.warning(
                            self, tr("Atlas processing error"),
                            tr("Error creating %s." % outputFileName))
                        return

                progress = QProgressDialog(tr("Rendering maps..."),
                                           tr("Abort"), 0, atlas.numFeatures(),
                                           self)
                QApplication.setOverrideCursor(Qt.BusyCursor)

                for featureI in range(0, atlas.numFeatures()):
                    progress.setValue(featureI + 1)
                    # process input events in order to allow aborting
                    QCoreApplication.processEvents()
                    if progress.wasCanceled():
                        atlas.endRender()
                        break
                    if not atlas.prepareForFeature(featureI):
                        QMessageBox.warning(self, tr("Atlas processing error"),
                                            tr("Atlas processing error"))
                        progress.cancel()
                        QApplication.restoreOverrideCursor()
                        return
                    if not self.ui.SingleFileCheckbox.checkState():
                        multiFilePrinter = QPrinter()
                        outputFileName = QDir(outputDir).filePath(
                            atlas.currentFilename()) + ".pdf"
                        self.composition.beginPrintAsPDF(
                            multiFilePrinter, outputFileName)
                        # set the correct resolution
                        self.composition.beginPrint(multiFilePrinter)
                        printReady = painter.begin(multiFilePrinter)
                        if not printReady:
                            QMessageBox.warning(
                                self, tr("Atlas processing error"),
                                tr("Error creating %s." % outputFileName))
                            progress.cancel()
                            QApplication.restoreOverrideCursor()
                            return
                        self.composition.doPrint(multiFilePrinter, painter)
                        painter.end()
                    else:
                        # start print on a new page if we're not on the first feature
                        if featureI > 0:
                            printer.newPage()
                        self.composition.doPrint(printer, painter)

                atlas.endRender()
                if self.ui.SingleFileCheckbox.checkState():
                    painter.end()
                QApplication.restoreOverrideCursor()

            elif self.ui.OutputTab.currentIndex() == 1:  # to Printer
                # if To Printer is selected set the printer
                # setting up printer
                if self.printer is None:
                    self.printer = QPrinter()
                    self.printer.setFullPage(True)
                    self.printer.setColorMode(QPrinter.Color)
                # open printer setting dialog
                pdlg = QPrintDialog(self.printer, self)
                pdlg.setModal(True)
                pdlg.setOptions(QAbstractPrintDialog.None)
                if not pdlg.exec_() == QDialog.Accepted:
                    return

                QApplication.setOverrideCursor(Qt.BusyCursor)
                #prepare for first feature, so that we know paper size to begin with
                self.composition.setAtlasMode(QgsComposition.ExportAtlas)
                atlas.prepareForFeature(0)

                # set orientation
                if self.composition.paperWidth(
                ) > self.composition.paperHeight():
                    self.printer.setOrientation(QPrinter.Landscape)
                    self.printer.setPaperSize(
                        QSizeF(self.composition.paperHeight(),
                               self.composition.paperWidth()),
                        QPrinter.Millimeter)
                else:
                    self.printer.setOrientation(QPrinter.Portrait)
                    self.printer.setPaperSize(
                        QSizeF(self.composition.paperWidth(),
                               self.composition.paperHeight()),
                        QPrinter.Millimeter)
                self.printer.setResolution(self.composition.printResolution())

                self.composition.beginPrint(self.printer)
                painter = QPainter(self.printer)
                if not len(atlas.featureFilterErrorString()) == 0:
                    QMessageBox.warning(
                        self, tr("Atlas processing error"),
                        tr("Feature filter parser error: %s" %
                           atlas.featureFilterErrorString()))
                    QApplication.restoreOverrideCursor()
                    return

                atlas.beginRender()
                progress = QProgressDialog(tr("Rendering maps..."),
                                           tr("Abort"), 0, atlas.numFeatures(),
                                           self)
                for featureI in range(0, atlas.numFeatures()):
                    progress.setValue(featureI + 1)
                    # process input events in order to allow cancelling
                    QCoreApplication.processEvents()
                    if progress.wasCanceled():
                        atlas.endRender()
                        break
                    if not atlas.prepareForFeature(featureI):
                        QMessageBox.warning(self, tr("Atlas processing error"),
                                            tr("Atlas processing error"))
                        progress.cancel()
                        QApplication.restoreOverrideCursor()
                        return

                    # start print on a new page if we're not on the first feature
                    if featureI > 0:
                        self.printer.newPage()
                    self.composition.doPrint(self.printer, painter)

                atlas.endRender()
                painter.end()
                QApplication.restoreOverrideCursor()

            elif self.ui.OutputTab.currentIndex() == 2:  # to Composer View
                # create new composer
                self.composition.setAtlasMode(QgsComposition.PreviewAtlas)
                composer.composerWindow().on_mActionAtlasPreview_triggered(
                    True)
                atlas.parameterChanged.emit()
                # Increase the reference count of the composer object
                # for not being garbage collected.
                # If not doing this composer would lost reference and qgis would crash
                # when referring to this composer object or at quit.
                ctypes.c_long.from_address(id(composer)).value += 1
        else:
            # if batch_plotting is False open a QgsComposerView with current map canvas
            cmap = self.composition.getComposerMapById(0)
            # set the new extent of composer map item
            newextent = self.iface.mapCanvas().mapRenderer().extent()
            currentextent = cmap.extent()
            canvas_ratio = newextent.width() / newextent.height()
            map_ratio = currentextent.width() / currentextent.height()
            if map_ratio < canvas_ratio:
                dh = newextent.width() / map_ratio - newextent.height()
                newextent.setYMinimum(newextent.yMinimum() - dh / 2)
                newextent.setYMaximum(newextent.yMaximum() + dh / 2)
            else:
                dw = map_ratio * newextent.height() - newextent.width()
                newextent.setXMinimum(newextent.xMinimum() - dw / 2)
                newextent.setXMaximum(newextent.xMaximum() + dw / 2)
            cmap.setNewExtent(newextent)
            # set the new scale of composer map item
            if scale > 0:
                cmap.setNewScale(scale)
            sc = cmap.scale()
            # set the grid interval according to the scale
            cmap.setGridIntervalX(sc / 10)
            cmap.setGridIntervalY(sc / 10)
            # Increase the reference count of the composer object
            # for not being garbage collected.
            # If not doing this composer would lost reference and qgis would crash
            # when referring to this composer object or at quit.
            ctypes.c_long.from_address(id(composer)).value += 1

        self.accept()
Пример #55
0
def print_(doc, filename=None, widget=None):
    """Prints the popplerqt4.Poppler.Document.
    
    The filename is used in the dialog and print job name.
    If the filename is not given, it defaults to a translation of "PDF Document".
    The widget is a widget to use as parent for the print dialog etc.
    
    """
    # Decide how we will print.
    # on Windows and Mac OS X a print command must be specified, otherwise
    # we'll use raster printing
    s = QSettings()
    s.beginGroup("helper_applications")
    cmd = s.value("printcommand", "", type(""))
    use_dialog = s.value("printcommand/dialog", False, bool)
    resolution = s.value("printcommand/dpi", 300, int)
    linux_lpr = False

    if os.name != 'nt' and not sys.platform.startswith('darwin'):
        # we're probably on Linux
        if not cmd:
            cmd = fileprinter.lprCommand()
            if cmd:
                linux_lpr = True
        elif cmd.split('/')[-1] in fileprinter.lpr_commands:
            linux_lpr = True

    print_file = filename
    title = os.path.basename(filename) if filename else _("PDF Document")
    printer = QPrinter()
    printer.setDocName(title)
    printer.setPrintRange(QPrinter.AllPages)

    if linux_lpr or use_dialog or not cmd:
        dlg = QPrintDialog(printer, widget)
        dlg.setMinMax(1, doc.numPages())
        dlg.setOption(QPrintDialog.PrintToFile, False)
        dlg.setWindowTitle(
            app.caption(_("Print {filename}").format(filename=title)))

        result = dlg.exec_()
        if widget:
            dlg.deleteLater()  # because it has a parent
        if not result:
            return  # cancelled

    if linux_lpr or '$ps' in cmd:
        # make a PostScript file with the desired paper size
        ps = QTemporaryFile()
        if ps.open() and qpopplerview.printer.psfile(doc, printer, ps):
            ps.close()
            print_file = ps.fileName()
    elif cmd:
        if printer.printRange() != QPrinter.AllPages:
            cmd = None  # we can't cut out pages from a PDF file
        elif '$pdf' not in cmd:
            cmd += ' $pdf'

    command = []
    if linux_lpr:
        # let all converted pages print
        printer.setPrintRange(QPrinter.AllPages)
        command = fileprinter.printCommand(cmd, printer, ps.fileName())
    elif cmd and print_file:
        for arg in helpers.shell_split(cmd):
            if arg in ('$ps', '$pdf'):
                command.append(print_file)
            else:
                arg = arg.replace('$printer', printer.printerName())
                command.append(arg)
    if command:
        if subprocess.call(command):
            QMessageBox.warning(
                widget, _("Printing Error"),
                _("Could not send the document to the printer."))
        return
    else:
        # Fall back printing of rendered raster images.
        # It is unsure if the Poppler ArthurBackend ever will be ready for
        # good rendering directly to a painter, so we'll fall back to using
        # raster images.

        p = Printer()
        p.setDocument(doc)
        p.setPrinter(printer)
        p.setResolution(resolution)

        d = QProgressDialog()
        d.setModal(True)
        d.setMinimumDuration(0)
        d.setRange(0, len(p.pageList()) + 1)
        d.canceled.connect(p.abort)

        def progress(num, total, page):
            d.setValue(num)
            d.setLabelText(
                _("Printing page {page} ({num} of {total})...").format(
                    page=page, num=num, total=total))

        def finished():
            p.deleteLater()
            d.deleteLater()
            d.hide()
            if not p.success and not p.aborted():
                QMessageBox.warning(
                    widget, _("Printing Error"),
                    _("Could not send the document to the printer."))

        p.finished.connect(finished)
        p.printing.connect(progress)
        p.start()
Пример #56
0
 def pbtnPrintClicked(self):
     dialog = QPrintDialog()
     if dialog.exec_() == QDialog.Accepted:
         self.dlg.txtFeedback.document().print_(dialog.printer())