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


Python QPrinter.setOrientation方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QPrinter.setOrientation方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.setOrientation方法的具体用法?Python QPrinter.setOrientation怎么用?Python QPrinter.setOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QPrinter的用法示例。


在下文中一共展示了QPrinter.setOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printProfile

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
    def printProfile(self):
        printer = QPrinter(QPrinter.HighResolution)
        printer.setOutputFormat(QPrinter.PdfFormat)
        printer.setPaperSize(QPrinter.A4)
        printer.setOrientation(QPrinter.Landscape)

        printpreviewdlg = QPrintPreviewDialog()
        printpreviewdlg.paintRequested.connect(self.printRequested)

        printpreviewdlg.exec_()
开发者ID:QGEP,项目名称:qgepplugin,代码行数:12,代码来源:qgepplotsvgwidget.py

示例2: exportPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
    def exportPDF(self, view, file_name, width, height):
        pdf = QPrinter()
        pdf.setOutputFormat(QPrinter.PdfFormat)
        pdf.setPrintRange(QPrinter.AllPages)
        pdf.setOrientation(QPrinter.Portrait)
        pdf.setResolution(QPrinter.HighResolution)
        pdf.setPaperSize(QSizeF(width, height), QPrinter.Point)
        pdf.setFullPage(True)
        pdf.setOutputFileName(file_name)
        view.mainFrame().print_(pdf)

        QApplication.restoreOverrideCursor()
开发者ID:danielfmva,项目名称:ert,代码行数:14,代码来源:export_plot.py

示例3: print_pdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
	def print_pdf(self):
		if self.deck is not None:
			#Setting the printer
			printer = QPrinter(QPrinter.HighResolution)
			printer.setOutputFormat(QPrinter.PdfFormat)
			printer.setOrientation(getattr(QPrinter, "Portrait"))
			printer.setOutputFileName(self.path)
			printer.setPaperSize(getattr(QPrinter, self.paper))
			printer.setFullPage(True)
			guide = self.max_cards()
			printer.setOrientation(getattr(QPrinter, guide["orientation"]))
			print guide, self.card_size
			#Start printing
			with QPainter(printer) as paint:
				ind = 0
				resol = printer.resolution()
				for c in self.deck:
						c.resize(self.card_size[0], self.card_size[1])
						if ind == guide["max"]:
							printer.newPage()
							ind = 0

						col = ind % guide["horizontal"]
						fil = ind // guide["horizontal"]
						print ind, fil, col
						target = QRectF((col)*self.card_size[0]*resol, (fil)*self.card_size[1]*resol,
									self.card_size[0]*resol, self.card_size[1]*resol)

						self.preview_card(c)
						self.scene.render(paint, target=target, source=QRectF(0,0,c.width(),c.height()))
						ind += 1
开发者ID:Ja-vi,项目名称:pnp,代码行数:33,代码来源:printer.py

示例4: printPage

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
def printPage(ok):
    printer = QPrinter()
    printer.setOutputFormat(QPrinter.PdfFormat)
    printer.setOrientation(QPrinter.Landscape)
    printer.setPageMargins(0.1,0.1,0.1,0.1, QPrinter.Millimeter)
    printer.setOutputFileName(sys.argv[2])
    view.print_(printer)    
    app.exit()
开发者ID:anjohnson,项目名称:pvDataWWW,代码行数:10,代码来源:qtweb.py

示例5: WebKitPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
class WebKitPDF ( QObject ):

  def __init__ ( self, url, dest ):
    QObject.__init__ ( self )
    self.dest = dest
    self.page = QtWebKit.QWebPage ( self )
    self.mainFrame = self.page.mainFrame()
    self.mainFrame.load ( QUrl ( url ) )

    # Settings
    # Disable the scrollbars
    self.mainFrame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
    self.mainFrame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)

    self.connect ( self.page,
             SIGNAL ( "loadProgress(int)" ),
             self.loadProgress )

    self.connect ( self.page,
             SIGNAL ( "loadFinished(bool)" ),
             self.renderPDF )



  def loadProgress ( self, progress ):
    print "Progress: ", progress


  def renderPDF ( self, status ):
    print "Load finished with status: ", status
    print "Rendering PDF ..."

    contentsSize = self.mainFrame.contentsSize()
    contentsSize.setWidth(1280)
    self.page.setViewportSize ( contentsSize )

    self.printer = QPrinter ( QPrinter.PrinterResolution )
    #self.printer = QPrinter ( QPrinter.ScreenResolution )
    self.printer.setOutputFormat ( QPrinter.PdfFormat )
    #self.printer.setPaperSize ( QPrinter.A4 )
    self.printer.setFullPage( True )
    self.printer.setPaperSize ( QSizeF( contentsSize ), QPrinter.DevicePixel )
    self.printer.setOrientation ( QPrinter.Portrait )
    self.printer.setOutputFileName ( self.dest )

    self.painter = QPainter ( self.printer )
    self.painter.setRenderHint ( QPainter.Antialiasing )
    self.mainFrame.render ( self.painter )
    self.painter.end()
    app = QtGui.QApplication.instance()
    app.exit ( 0 )
开发者ID:kholidfu,项目名称:htmlkepdf,代码行数:53,代码来源:gistfile2.py

示例6: render_pdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
 def render_pdf(self, page, fileName, paperSize=None):
     """Renders the page into a pdf
     :param page: The webpage that we want to render
     :param fileName: The path where we want to save the pdf.
         For example /home/user/mypdf.pdf
     :param paperSize: An PaperSize object that will be used
         to render the webpage
     """
     mainFrame = page.currentFrame()
     
     printer = QPrinter()
     printer.setOutputFormat(QPrinter.PdfFormat)
     printer.setOutputFileName(fileName)
     printer.setResolution(self._get_default_dpi())
     
     if paperSize is None:
         ps = mainFrame.contentsSize()
         paperSize = PaperSize(width=ps.width(),
                 height=ps.width(),
                 margin=(0, 0, 0, 0),
                 orientation=None,
                 page_type=None)
         
     
     if paperSize.page_type is not None:
         if paperSize.orientation.lower() == "landscape":
             orientation = QPrinter.Landscape
         else:
             orientation = QPrinter.Portrait
         printer.setOrientation(orientation)
         
         printer.setPaperSize(QPrinter.A4) # Fallback
         for f in self.PAGE_TYPE:
             if paperSize.page_type.lower() == f[0].lower():
                 printer.setPaperSize(f[1])
                 break
     else:
         sizePt = QSizeF(paperSize.width, 
                         paperSize.height)
         printer.setPaperSize(sizePt, QPrinter.Point)
        
     printer.setPageMargins(paperSize.margin[0],
                            paperSize.margin[1],
                            paperSize.margin[2],
                            paperSize.margin[3],
                            QPrinter.Point)
     mainFrame.print_(printer)
开发者ID:a1939228,项目名称:Ghost.py,代码行数:49,代码来源:pdf.py

示例7: print_grid

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
	def print_grid(self):
		if self.deck is not None:
			#Setting the printer
			printer = QPrinter(QPrinter.HighResolution)
			printer.setOutputFormat(QPrinter.PdfFormat)
			printer.setOrientation(getattr(QPrinter, self.orientation))
			printer.setOutputFileName(self.path)
			printer.setPaperSize(getattr(QPrinter, self.paper))
			#Start printing
			with QPainter(printer) as paint:
				first = True
				for c in self.deck:
					if not first:
						printer.newPage()
					first = False
					self.preview_card(c)
					self.scene.render(paint)
开发者ID:Ja-vi,项目名称:pnp,代码行数:19,代码来源:printer.py

示例8: __outPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
 def __outPDF(self):
     """
     To save the profile as pdf file
     """
     fileName = QFileDialog.getSaveFileName(
         self.__iface.mainWindow(), QCoreApplication.translate("VDLTools", "Save As"),
         QCoreApplication.translate("VDLTools", "Profile.pdf"),"Portable Document Format (*.pdf)")
     if fileName is not None:
         if self.__lib == 'Qwt5':
             printer = QPrinter()
             printer.setCreator(QCoreApplication.translate("VDLTools", "QGIS Profile Plugin"))
             printer.setOutputFileName(fileName)
             printer.setOutputFormat(QPrinter.PdfFormat)
             printer.setOrientation(QPrinter.Landscape)
             self.__plotWdg.print_(printer)
         elif self.__lib == 'Matplotlib':
             self.__plotWdg.figure.savefig(str(fileName))
开发者ID:gusthiot,项目名称:VDLTools,代码行数:19,代码来源:profile_dock_widget.py

示例9: renderPdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
    def renderPdf(self, fileName):
        p = QPrinter()
        p.setOutputFormat(QPrinter.PdfFormat)
        p.setOutputFileName(fileName)
        p.setResolution(pdf_dpi)
        paperSize = self.m_paperSize

        if not len(paperSize):
            pageSize = QSize(self.m_page.mainFrame().contentsSize())
            paperSize['width'] = str(pageSize.width()) + 'px'
            paperSize['height'] = str(pageSize.height()) + 'px'
            paperSize['border'] = '0px'

        if paperSize.get('width') and paperSize.get('height'):
            sizePt = QSizeF(ceil(self.stringToPointSize(paperSize['width'])),
                            ceil(self.stringToPointSize(paperSize['height'])))
            p.setPaperSize(sizePt, QPrinter.Point)
        elif 'format' in paperSize:
            orientation = QPrinter.Landscape if paperSize.get('orientation') and paperSize['orientation'].lower() == 'landscape' else QPrinter.Portrait
            orientation = QPrinter.Orientation(orientation)
            p.setOrientation(orientation)

            formats = {
                'A3': QPrinter.A3,
                'A4': QPrinter.A4,
                'A5': QPrinter.A5,
                'Legal': QPrinter.Legal,
                'Letter': QPrinter.Letter,
                'Tabloid': QPrinter.Tabloid
            }

            p.setPaperSize(QPrinter.A4) # fallback
            for format, size in formats.items():
                if format.lower() == paperSize['format'].lower():
                    p.setPaperSize(size)
                    break
        else:
            return False

        border = floor(self.stringToPointSize(paperSize['border'])) if paperSize.get('border') else 0
        p.setPageMargins(border, border, border, border, QPrinter.Point)

        self.m_page.mainFrame().print_(p)
        return True
开发者ID:10git,项目名称:TheObserver,代码行数:46,代码来源:phantom.py

示例10: open_html_in_print_preview_from_gui_thread

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
def open_html_in_print_preview_from_gui_thread(html,
    html_document=QTextDocument, page_size=None, page_orientation=None):

     printer = QPrinter()
     printer.setPageSize(page_size or QPrinter.A4)
     printer.setOrientation(page_orientation or QPrinter.Portrait)
     dialog = QPrintPreviewDialog(printer)

     @QtCore.pyqtSlot(QPrinter)
     def render(printer):
         doc = html_document()
         doc.setHtml(html)
         doc.print_(printer)

     dialog.paintRequested.connect(render)
     # show maximized seems to trigger a bug in qt which scrolls the page down
     #dialog.showMaximized()
     desktop = QCoreApplication.instance().desktop()
     # use the size of the desktop instead to set the dialog size
     dialog.resize(desktop.width() * 0.75, desktop.height() * 0.75)
     dialog.exec_()
开发者ID:kurtraschke,项目名称:camelot,代码行数:23,代码来源:printer.py

示例11: preview

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
 def preview(self):
     """
     Muestra el dialogo de vista previa de impresión
     """
     try:
         printer = QPrinter()
         printer.setOrientation(self.orientation)
         printer.setPageSize(self.pageSize)
         web = self.web + self.printIdentifier
         report = reports.frmReportes(web, printer, self)
         report.exec_()
     except NotImplementedError as inst:
         QMessageBox.information(
             self, qApp.organizationName(), u"No se ha implementado la función de impresión para este modulo"
         )
         logging.error(unicode(inst))
     except UserWarning as inst:
         QMessageBox.critical(self, qApp.organizationName(), unicode(inst))
         logging.error(unicode(inst))
     except Exception as inst:
         QMessageBox.critical(self, qApp.organizationName(), "Hubo un error al intentar mostrar su reporte")
         logging.critical(unicode(inst))
开发者ID:armonge,项目名称:EsquipulasPy,代码行数:24,代码来源:base.py

示例12: saveWindow

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
 def saveWindow(self):
     fileTypes = {'PDF':('pdf',), 'Postscript':('ps',),'SVG':('svg',)}
     filters = ';;'.join(['%s (%s)' % (k, ' '.join(['*.'+e for e in v])) for k, v in fileTypes.items()])
     dlg = QFileDialog(self,
         QCoreApplication.translate('QwtPlot', 'Select type and name of file to save'),
         SimuVis4.Globals.defaultFolder or '', filters)
     dlg.setFileMode(QFileDialog.AnyFile)
     dlg.setAcceptMode(QFileDialog.AcceptSave)
     if dlg.exec_() != QDialog.Accepted:
         return
     tmp = str(dlg.selectedFilter())
     fileType = tmp[:tmp.find('(')-1]
     dlg.setDefaultSuffix(fileTypes[fileType][0])
     files = dlg.selectedFiles()
     if not files:
         return
     fileName = unicode(files[0])
     SimuVis4.Globals.defaultFolder, tmp = os.path.split(fileName)
     if fileType == 'PDF':
         printer = QPrinter()
         printer.setOutputFormat(QPrinter.PdfFormat)
         printer.setOrientation(QPrinter.Landscape)
         printer.setOutputFileName(fileName)
         printer.setCreator('SimuVis4')
         self.plot.print_(printer)
     elif fileType == 'Postscript':
         printer = QPrinter()
         printer.setOutputFormat(QPrinter.PostScriptFormat)
         printer.setOrientation(QPrinter.Landscape)
         printer.setOutputFileName(fileName)
         printer.setCreator('SimuVis4')
         self.plot.print_(printer)
     elif fileType == 'SVG':
         generator = QSvgGenerator()
         generator.setFileName(fileName)
         generator.setSize(QSize(800, 600))
         self.plot.print_(generator)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:39,代码来源:QwtPlotWindow.py

示例13: Ventana_Imprimir

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
class Ventana_Imprimir(QtGui.QDialog):

    def __init__(self, parent=None, datos=None):

        self.parent = parent
        self.transito = datos
        super(Ventana_Imprimir, self).__init__(parent=self.parent)
        self.setGeometry(30, 40, 800, 500)
        self.setWindowTitle("Imprimir albaran")

        self.init_controles()

        #self.navegador.setUrl(QUrl('http://www.google.es'))
        self.navegador.setHtml(self.leer_plantilla_y_poner_datos())
        #self.navegador.loadFinished.connect(lambda: self.LoadEnd())

    def leer_plantilla_y_poner_datos(self):
        html = open(PLANTILLA_ALBARAN).read()

        if self.transito is None:
            html = """
            <!DOCTYPE html>
            <html lang="es">
            <head>
                <meta charset="UTF-8">
                <title></title>
            </head>
            <body >
                <h1 style='color:red;'>NO HAY DATOS QUE PRESENTAR</h1>
            </body>
            </html>
            """
        else:
            #pongamos los datos
            #self.transito = Historico()
            html = html.replace("@num_albaran", str(self.transito.num_albaran))
            html = html.replace("@mat_cabina", self.transito.mat_cabina)
            html = html.replace("@mat_remolque", self.transito.mat_remolque)

            html = html.replace("@cliente", self.transito.razon_social_cliente)
            html = html.replace("@producto", self.transito.nombre_producto)
            html = html.replace("@proveedor", self.transito.razon_social_proveedor)
            html = html.replace("@poseedor", self.transito.razon_social_poseedor)
            html = html.replace("@agencia", self.transito.razon_social_agencia)
            html = html.replace("@conductor", self.transito.nombre_conductor)
            html = html.replace("@origen", self.transito.origen)
            html = html.replace("@destino", self.transito.destino)
            html = html.replace("@fech_entrada", self.transito.fecha_entrada)
            html = html.replace("@fech_salida", self.transito.fecha_salida)
            html = html.replace("@peso_entrada", str(self.transito.bruto))
            html = html.replace("@peso_salida", str(self.transito.tara))
            html = html.replace("@neto", str(self.transito.neto))

        return html

    def printPreview(self):

        dialog = QtGui.QPrintPreviewDialog(self.printer)
        dialog.setWindowState(Qt.WindowMaximized)
        #dialog.paintRequested.connect(self.print_)
        dialog.setWindowFlags(Qt.CustomizeWindowHint |
                              Qt.WindowTitleHint |
                              Qt.WindowMinMaxButtonsHint |
                              Qt.WindowCloseButtonHint |
                              Qt.WindowContextHelpButtonHint)
        dialog.exec()

    def imprimir(self):
        print('Prepandando impresion')

        self.printer = QPrinter(QPrinter.HighResolution);
        self.printer.setPageSize(QPrinter.A4);
        self.printer.setOrientation(QPrinter.Portrait);
        self.printer.setPageMargins(10, 10, 10, 10, QPrinter.Millimeter)
        self.navegador.print_(self.printer)

    def LoadEnd(self):

        #self.printer = QPrinter( QPrinter.HighResolution )
        #self.printer.setOutputFormat( QPrinter.PdfFormat )
        #self.printer.setOutputFileName( "out.pdf" )
        #self.printPreview()
        #self.navegador.print_( self.printer )
        pass

    def init_controles(self):
        vbox = QtGui.QVBoxLayout()

        self.navegador = QtWebKit.QWebView(self)
        self.btnImprimir = QtGui.QPushButton(IMPRIMIR, self)
        self.btnImprimir.clicked.connect(lambda: self.imprimir())

        vbox.addWidget(self.btnImprimir)
        vbox.addWidget(self.navegador)

        self.setLayout(vbox)
开发者ID:arkadoel,项目名称:openbascula,代码行数:98,代码来源:Dialogo_impresion.py

示例14: renderPdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
    def renderPdf(self, fileName):
        p = QPrinter()
        p.setOutputFormat(QPrinter.PdfFormat)
        p.setOutputFileName(fileName)
        p.setResolution(pdf_dpi)
        paperSize = self.m_paperSize

        if not len(paperSize):
            pageSize = QSize(self.m_webPage.mainFrame().contentsSize())
            paperSize['width'] = str(pageSize.width()) + 'px'
            paperSize['height'] = str(pageSize.height()) + 'px'
            paperSize['border'] = '0px'

        if paperSize.get('width') and paperSize.get('height'):
            sizePt = QSizeF(ceil(self.stringToPointSize(paperSize['width'])),
                            ceil(self.stringToPointSize(paperSize['height'])))
            p.setPaperSize(sizePt, QPrinter.Point)
        elif 'format' in paperSize:
            orientation = QPrinter.Landscape if paperSize.get('orientation') and paperSize['orientation'].lower() == 'landscape' else QPrinter.Portrait
            orientation = QPrinter.Orientation(orientation)
            p.setOrientation(orientation)

            formats = {
                'A0': QPrinter.A0,
                'A1': QPrinter.A1,
                'A2': QPrinter.A2,
                'A3': QPrinter.A3,
                'A4': QPrinter.A4,
                'A5': QPrinter.A5,
                'A6': QPrinter.A6,
                'A7': QPrinter.A7,
                'A8': QPrinter.A8,
                'A9': QPrinter.A9,
                'B0': QPrinter.B0,
                'B1': QPrinter.B1,
                'B2': QPrinter.B2,
                'B3': QPrinter.B3,
                'B4': QPrinter.B4,
                'B5': QPrinter.B5,
                'B6': QPrinter.B6,
                'B7': QPrinter.B7,
                'B8': QPrinter.B8,
                'B9': QPrinter.B9,
                'B10': QPrinter.B10,
                'C5E': QPrinter.C5E,
                'Comm10E': QPrinter.Comm10E,
                'DLE': QPrinter.DLE,
                'Executive': QPrinter.Executive,
                'Folio': QPrinter.Folio,
                'Ledger': QPrinter.Ledger,
                'Legal': QPrinter.Legal,
                'Letter': QPrinter.Letter,
                'Tabloid': QPrinter.Tabloid
            }

            p.setPaperSize(QPrinter.A4) # fallback
            for format, size in formats.items():
                if format.lower() == paperSize['format'].lower():
                    p.setPaperSize(size)
                    break
        else:
            return False

        border = floor(self.stringToPointSize(paperSize['border'])) if paperSize.get('border') else 0
        p.setPageMargins(border, border, border, border, QPrinter.Point)

        self.m_webPage.mainFrame().print_(p)
        return True
开发者ID:capetown,项目名称:phantomjs,代码行数:70,代码来源:webpage.py

示例15: GanttPrintHandler

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOrientation [as 别名]
class GanttPrintHandler(PrintHandler):
    def __init__(self, ganttWidget):
        super(GanttPrintHandler, self).__init__()
        self._printer = None
        self.ganttWidget = ganttWidget
        self._pri = Namespace()

    def printer(self):
        if self._printer is None:
            self._printer = QPrinter(QPrinter.HighResolution)
            self._printer.setOrientation(QtGui.QPrinter.Landscape)
            self._printer.setFullPage(True)
            #self.translate(-15, -15)
        self._printer.setDocName(self.ganttWidget.ganttModel.name)
        return self._printer

    def createPreviewDialog(self, printer):
        return MyPrintPreviewDialog(self.ganttWidget, printer)

    @property
    def horizontalPageCount(self):
        return settings.print.HORIZONTAL_PAGE_COUNT

    def pageCount(self):
        self.preparePrint(self.printer())
        return len(self._pageInfo)

    def preparePrint(self, printer):
        """druckenの前準備。派生クラスでオーバライド"""
        #drucken用のWidgetを用意する
        self._widget = GanttWidget()
        self._widget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._widget.ganttModel = self.ganttWidget.ganttModel

        self._pri = self.getPrintRectInfo(printer)
        self._widget.setGeometry(QRect(0, 0,
            self._pri.log.headerWidth + self._pri.log.bodyWidth,
            self._pri.log.headerHeight + self._pri.log.bodyHeight))

        #各ページの表示範囲を算出する
        self._pageInfo = []
        bh = self._pri.log.bodyHeight
        top = 0
        while bh > 0:
            if bh < self._pri.log.bodyHeightPerPage:
                height = bh
            else:
                height = self._pri.log.bodyHeightPerPage
            #----
            bw = self._pri.log.bodyWidth
            left = 0
            while bw > 0:
                if bw < self._pri.log.bodyWidthPerPage:
                    width = bw
                else:
                    width = self._pri.log.bodyWidthPerPage
                self._pageInfo.append(QRect(left, top, width, height))
                left += width
                bw -= width
            #----
            top += height
            bh -= height
        print("self._pageInfo:", self._pageInfo)

    def getPrintRectInfo(self, printer):
        bodyHeight = 0
        it = QtGui.QTreeWidgetItemIterator(self._widget,
                                    QtGui.QTreeWidgetItemIterator.NotHidden)
        while it.value():
            #rect = self.visualRect(self.indexFromItem(it.value()))
            #rowHeight = self.rowHeight(self.indexFromItem(it.value()))
            #print(rect, rowHeight)
            #visualRect, rowHeightで取得できる高さが実際の行高さよりも小さいので
            #定数値を足し込んでおくことにする
            bodyHeight += ROW_HEIGHT
            it += 1
        obj = Namespace()
        obj.dev = Namespace()
        obj.log = Namespace()
        obj.scl = Namespace()
        print("settings.columnWidth", settings.columnWidth)
        obj.log.headerWidth = settings.getHeaderWidth()
        obj.log.headerHeight = HEADER_HEIGHT
        obj.log.bodyWidth    = self._widget.preferableWidth()
        obj.log.bodyHeight   = bodyHeight
        obj.log.bodyWidthPerPage = obj.log.bodyWidth / self.horizontalPageCount
        obj.log.bodyHeightPerPage = ROW_HEIGHT * settings.print.ROWS_PER_PAGE
        obj.log.pageWidth = obj.log.headerWidth + obj.log.bodyWidthPerPage
        obj.log.pageHeight = obj.log.headerHeight + obj.log.bodyHeightPerPage
        pageRect = printer.pageRect()
        obj.dev.pageWidth = pageRect.width()
        obj.dev.pageHeight = pageRect.height()
        obj.dev.headerWidth = obj.dev.pageWidth * settings.print.HEADER_WIDTH_RATIO
        obj.dev.headerHeight = obj.dev.pageHeight * settings.print.HEADER_HEIGHT_RATIO
        obj.dev.bodyWidth    = obj.dev.pageWidth - obj.dev.headerWidth
        obj.dev.bodyHeight   = obj.dev.pageHeight - obj.dev.headerHeight
        obj.scl.headerWidth = obj.dev.headerWidth / obj.log.headerWidth
        obj.scl.headerHeight = obj.dev.headerHeight / obj.log.headerHeight
        obj.scl.bodyWidth = obj.dev.bodyWidth / obj.log.bodyWidthPerPage
        obj.scl.bodyHeight = obj.dev.bodyHeight / obj.log.bodyHeightPerPage
#.........这里部分代码省略.........
开发者ID:sebastianelsner,项目名称:pmp,代码行数:103,代码来源:printhandler.py


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