Beispiel #1
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())
Beispiel #2
0
    def __print(self, dialog):

        if not self.printer:
            self.printer = QPrinter()
        self._preview(dialog, False)
        selected_com = self._get_current_composer()
        if selected_com is None:
            return

        printdialog = QPrintDialog(self.printer)
        if printdialog.exec_() != QDialog.Accepted:
            return

        actual_printer = QgsLayoutExporter(selected_com)
        # The correct instruction for python3 is:
        # success = actual_printer.print(self.printer, QgsLayoutExporter.PrintExportSettings())
        # but python2 produces an error in the word 'print' at actual_printer.print(...),
        # then we need to create a fake to cheat python2
        print_ = getattr(actual_printer, 'print')
        print_(self.printer, QgsLayoutExporter.PrintExportSettings())
Beispiel #3
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))
Beispiel #4
0
 def print_(self):
     printer = QPrinter()
     dlg = QPrintDialog(printer)
     if dlg.exec_() == QDialog.Accepted:
         self.tbEigentuemer.print_(printer)
Beispiel #5
0
 def print_(self):
     printer = QPrinter()
     dlg = QPrintDialog(printer)
     if dlg.exec_() == QDialog.Accepted:
         self.tbEigentuemer.print_(printer)