本文整理汇总了Python中PyQt4.QtGui.QPrinter类的典型用法代码示例。如果您正苦于以下问题:Python QPrinter类的具体用法?Python QPrinter怎么用?Python QPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPrinter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printProfile
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_()
示例2: printNote
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)
示例3: on_actionFitPage_triggered
def on_actionFitPage_triggered(self):
papersize = self._getPaperSize()
printer = QPrinter()
printer.setPaperSize(papersize)
widthInPixels = printer.pageRect().width()
maxColumns = self.songProperties.maxColumns(widthInPixels)
self.widthSpinBox.setValue(maxColumns)
self.scoreScene.reBuild()
示例4: on_actionPreview_activated
def on_actionPreview_activated( self ):
printer = QPrinter()
printer.setPageSize( QPrinter.Letter )
web = "balancegeneral.php?date=%d+%d" % (
self.dtPicker.date().month() ,
self.dtPicker.date().year() )
report = frmReportes( web , printer, self )
report.exec_()
示例5: printWindow
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())
示例6: on_actionPrint_triggered
def on_actionPrint_triggered(self):
if self._printer is None:
self._printer = QPrinter()
self._printer = QPrinter(QPrinterInfo(self._printer),
QPrinter.HighResolution)
self._printer.setPaperSize(self._getPaperSize())
dialog = QPrintPreviewDialog(self._printer, parent = self)
def updatePages(qprinter):
self.scoreScene.printScore(qprinter, self.scoreView)
dialog.paintRequested.connect(updatePages)
dialog.exec_()
示例7: printPage
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()
示例8: plotSVG
def plotSVG(self, width, height, output_file, _plotting_object = None):
"""Plots the data specified in the current input file as a page in a
PDF file with the given width and height, writing the output to the
specified output file. Returns the SVG object produced."""
printer = QPrinter()
svg = QSvgGenerator()
svg.setFileName(output_file)
svg.setSize(QSize(width, height))
svg.setViewBox(QRect(0, 0, width, height))
svg.setResolution(printer.resolution())
return self._plot(width, height, svg, _plotting_object)[0]
示例9: WebKitPDF
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 )
示例10: printWindow
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)
示例11: printBill
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)
示例12: __saveAsPDF
def __saveAsPDF( self, fileName ):
" Saves the flowchart as an PDF file "
printer = QPrinter()
printer.setOutputFormat( QPrinter.PdfFormat )
printer.setPaperSize( QSizeF( self.scene.width(),
self.scene.height() ), QPrinter.Point )
printer.setFullPage( True )
printer.setOutputFileName( fileName )
painter = QPainter( printer )
self.scene.render( painter )
painter.end()
return
示例13: __init__
def __init__(self, parent):
QFrame.__init__(self,parent)
self.filename = QString()
self.copiedItem = QByteArray()
self.pasteOffset = 5
self.prevPoint = QPoint()
self.addOffset = 5
self.screenSize = (320, 240)
self.bgColor = QColor(244,244,244)
'''0.Portrait 1.Landscape'''
self.orientation = 0
self.currentItem = None
self.printer = QPrinter(QPrinter.HighResolution)
self.printer.setPageSize(QPrinter.Letter)
'''Header'''
self.headingBar = HeadingBar(self)
'''WidgetsBar'''
self.widgetsBar = WidgetsBar(self)
'''Property'''
self.propertyBar = PropertyBar(self)
'''view'''
viewLayoutWidget = QFrame()
viewLayoutWidget.setFrameShape(QFrame.StyledPanel)
viewLayout = QHBoxLayout(viewLayoutWidget)
#viewLayout.setMargin(10)
self.view = ScreenView(viewLayoutWidget)
'''scene'''
self.scene = QGraphicsScene(self)
#self.scene.selectionChanged.connect(self.setConnect)
#self.view.setStyleSheet("border: 1px solid red;")
self.setBackgroundColor(self.bgColor)
self.setScreenSize(self.screenSize)
self.view.setScene(self.scene)
self.view.setAlignment(Qt.AlignCenter)
self.connect(self.view, SIGNAL("dropped"),self.addPixmapFile)
self.scroll_off = 1
self.setScrollBar()
viewLayout.setMargin(0)
viewLayout.addWidget(self.view)
self.wrapped = [] # Needed to keep wrappers alive
layout = QVBoxLayout(self)
layout.addWidget(self.headingBar)
layout.addWidget(viewLayoutWidget)
layout.addWidget(self.widgetsBar)
layout.addWidget(self.propertyBar)
layout.setMargin(0)
self.setLayout(layout)
示例14: imprimir
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)
示例15: printer
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