本文整理汇总了Python中PyQt5.QtPrintSupport.QPrinter.setFullPage方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.setFullPage方法的具体用法?Python QPrinter.setFullPage怎么用?Python QPrinter.setFullPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtPrintSupport.QPrinter
的用法示例。
在下文中一共展示了QPrinter.setFullPage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __printPreviewDiagram
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def __printPreviewDiagram(self):
"""
Private slot called to show a print preview of the diagram.
"""
from PyQt5.QtPrintSupport import QPrintPreviewDialog
printer = QPrinter(mode=QPrinter.ScreenResolution)
printer.setFullPage(True)
if Preferences.getPrinter("ColorMode"):
printer.setColorMode(QPrinter.Color)
else:
printer.setColorMode(QPrinter.GrayScale)
if Preferences.getPrinter("FirstPageFirst"):
printer.setPageOrder(QPrinter.FirstPageFirst)
else:
printer.setPageOrder(QPrinter.LastPageFirst)
printer.setPageMargins(
Preferences.getPrinter("LeftMargin") * 10,
Preferences.getPrinter("TopMargin") * 10,
Preferences.getPrinter("RightMargin") * 10,
Preferences.getPrinter("BottomMargin") * 10,
QPrinter.Millimeter
)
printer.setPrinterName(Preferences.getPrinter("PrinterName"))
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested[QPrinter].connect(self.__print)
preview.exec_()
示例2: printDiagram
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def printDiagram(self):
"""
Public slot called to print the diagram.
"""
printer = QPrinter(mode=QPrinter.ScreenResolution)
printer.setFullPage(True)
if Preferences.getPrinter("ColorMode"):
printer.setColorMode(QPrinter.Color)
else:
printer.setColorMode(QPrinter.GrayScale)
if Preferences.getPrinter("FirstPageFirst"):
printer.setPageOrder(QPrinter.FirstPageFirst)
else:
printer.setPageOrder(QPrinter.LastPageFirst)
printer.setPageMargins(
Preferences.getPrinter("LeftMargin") * 10,
Preferences.getPrinter("TopMargin") * 10,
Preferences.getPrinter("RightMargin") * 10,
Preferences.getPrinter("BottomMargin") * 10,
QPrinter.Millimeter
)
printerName = Preferences.getPrinter("PrinterName")
if printerName:
printer.setPrinterName(printerName)
printDialog = QPrintDialog(printer, self)
if printDialog.exec_():
super(UMLGraphicsView, self).printDiagram(
printer, self.diagramName)
示例3: __printPreviewImage
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def __printPreviewImage(self):
"""
Private slot to handle the Print Preview menu action.
"""
from PyQt5.QtPrintSupport import QPrintPreviewDialog
if self.mainWidget is None:
E5MessageBox.critical(
self,
self.tr("Print Preview"),
self.tr("""There is no UI file loaded."""))
return
settings = Preferences.Prefs.settings
printer = QPrinter(QPrinter.HighResolution)
printer.setFullPage(True)
printerName = Preferences.getPrinter("UIPreviewer/printername")
if printerName:
printer.setPrinterName(printerName)
printer.setPageSize(
QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
printer.setPageOrder(
QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
printer.setOrientation(QPrinter.Orientation(
int(settings.value("UIPreviewer/orientation"))))
printer.setColorMode(
QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode"))))
preview = QPrintPreviewDialog(printer, self)
preview.paintRequested.connect(self.__print)
preview.exec_()
示例4: printPdf
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def printPdf(self, frame):
element = self.getPostElement(frame.documentElement())
if element is not None:
rect = element.geometry()
pdf = QPrinter(QPrinter.ScreenResolution)
pdf.setFullPage(True)
pdf.setPrintRange(QPrinter.AllPages)
pdf.setOutputFileName(self.getName(element))
pdf.setOutputFormat(QPrinter.PdfFormat)
element.webFrame().print(pdf)
示例5: __printDiagram
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def __printDiagram(self):
"""
Private slot called to print the diagram.
"""
printer = QPrinter(mode=QPrinter.ScreenResolution)
printer.setFullPage(True)
if Preferences.getPrinter("ColorMode"):
printer.setColorMode(QPrinter.Color)
else:
printer.setColorMode(QPrinter.GrayScale)
if Preferences.getPrinter("FirstPageFirst"):
printer.setPageOrder(QPrinter.FirstPageFirst)
else:
printer.setPageOrder(QPrinter.LastPageFirst)
printer.setPrinterName(Preferences.getPrinter("PrinterName"))
printDialog = QPrintDialog(printer, self)
if printDialog.exec_():
self.__print(printer)
示例6: print_sheet
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def print_sheet(self):
printer = QPrinter(QPrinterInfo.defaultPrinter())
printer.setOutputFileName('foo.pdf')
printer.setResolution(72)
printer.setFullPage(True)
self.webRptView.print(printer)
pdf = 'foo.pdf'
AcroRD32Path = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, 'Software\\Adobe\\Acrobat\Exe')
acroread = AcroRD32Path
cmd= '{0} /N /T "{1}" ""'.format(acroread,pdf)
proc = subprocess.Popen(cmd)
time.sleep(5)
os.system('TASKKILL /F /IM AcroRD32.exe')
os.remove('foo.pdf')
示例7: exportToPDF
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def exportToPDF(self, path=None):
if path is None:
desktop = QStandardPaths.standardLocations(
QStandardPaths.DesktopLocation)
path = os.path.join(desktop[0], "metricsWindow.pdf")
printer = QPrinter(QPrinter.ScreenResolution)
printer.setOutputFileName(path)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setFullPage(True)
printer.setPaperSize(QSizeF(self.size()), QPrinter.DevicePixel)
painter = QPainter()
painter.begin(printer)
painter.setRenderHint(QPainter.Antialiasing)
if self._rightToLeft:
self.paintRightToLeft(painter, self.geometry())
else:
self.paintLeftToRight(painter, self.geometry())
painter.end()
示例8: __printImage
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
def __printImage(self):
"""
Private slot to handle the Print Image menu action.
"""
if self.mainWidget is None:
E5MessageBox.critical(
self,
self.tr("Print Image"),
self.tr("""There is no UI file loaded."""))
return
settings = Preferences.Prefs.settings
printer = QPrinter(QPrinter.HighResolution)
printer.setFullPage(True)
printerName = Preferences.getPrinter("UIPreviewer/printername")
if printerName:
printer.setPrinterName(printerName)
printer.setPageSize(
QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
printer.setPageOrder(
QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
printer.setOrientation(QPrinter.Orientation(
int(settings.value("UIPreviewer/orientation"))))
printer.setColorMode(
QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode"))))
printDialog = QPrintDialog(printer, self)
if printDialog.exec_() == QDialog.Accepted:
self.statusBar().showMessage(self.tr("Printing the image..."))
self.__print(printer)
settings.setValue("UIPreviewer/printername", printer.printerName())
settings.setValue("UIPreviewer/pagesize", printer.pageSize())
settings.setValue("UIPreviewer/pageorder", printer.pageOrder())
settings.setValue("UIPreviewer/orientation", printer.orientation())
settings.setValue("UIPreviewer/colormode", printer.colorMode())
self.statusBar().showMessage(
self.tr("Image sent to printer..."), 2000)
示例9: PrinterPyQt5
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
class PrinterPyQt5(Printer):
def __init__(self, page_size, print_pdf=False):
super().__init__(page_size)
self._printer = QPrinter(QPrinter.HighResolution)
self._printer.setPageSize(QtGui.QPageSize(QtCore.QSizeF(*page_size),
QtGui.QPageSize.Millimeter))
self._printer.setColorMode(QPrinter.Color)
logging.info('Using printer "%s"', self._printer.printerName())
self._print_pdf = print_pdf
if self._print_pdf:
logging.info('Using PDF printer')
self._counter = 0
self._printer.setOutputFormat(QPrinter.PdfFormat)
self._printer.setFullPage(True)
def print(self, picture):
if self._print_pdf:
self._printer.setOutputFileName('print_%d.pdf' % self._counter)
self._counter += 1
logging.info('Printing picture')
picture = picture.scaled(self._printer.paperRect().size(),
QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
printable_size = self._printer.pageRect(QPrinter.DevicePixel)
origin = ((printable_size.width() - picture.width()) // 2,
(printable_size.height() - picture.height()) // 2)
painter = QtGui.QPainter(self._printer)
painter.drawImage(QtCore.QPoint(*origin), picture)
painter.end()
示例10: ReportDialog
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setFullPage [as 别名]
#.........这里部分代码省略.........
Checks which button sent a signal. Based on that it either prints all images or just a single specific image.
"""
if (self.reportOption == 1):
for model in self.wholeList:
self.document.setHtml(self.createHtml(model, forPrinting=True))
self.printer.setOutputFileName(
self.savedfiles.parents[0].__str__() + '/' + self.savedfiles.name.replace("Image Name", "") + model.filename.stem + '.pdf')
self.document.print(self.printer)
elif (self.reportOption == 0):
self.document.print(self.printer)
elif (self.reportOption == 2):
self.merger = merger()
for model in self.wholeList:
self.document.setHtml(self.createHtml(model, forPrinting=True))
name = self.savedfiles.__str__() + '.pdf'
print(name)
self.printer.setOutputFileName(
self.savedfiles.parents[0].__str__() + '/' + self.savedfiles.name.replace("Image Name", "") + model.filename.stem + '.pdf')
self.document.print(self.printer)
input = open(self.savedfiles.parents[0].__str__() + '/' + self.savedfiles.name.replace("Image Name", "") + model.filename.stem + '.pdf', "rb")
self.merger.append(input)
os.remove(self.savedfiles.parents[0].__str__() + '/' + self.savedfiles.name.replace("Image Name", "") + model.filename.stem + '.pdf')
out = open(name, "wb")
self.merger.write(out)
self.merger.close()
def printerSetup(self):
"""
Sets up default instructions for printer.
"""
self.printer.setPageSize(QPrinter.Letter)
self.printer.setOutputFormat(QPrinter.PdfFormat)
self.printer.setFullPage(True)
self.printer.setOutputFileName(str(self.savedfiles)+".pdf")
def createHtml(self, model, forPrinting):
"""
Creates html-based report that shows the basic information about the sample.
"""
# for printing
if forPrinting:
html = """
<html>
<head>
<link type="text/css" rel="stylesheet" href="ntm_style.css"/>
</head>
<body>
<p> Image Name: {name} </p> <p> μ: {th}° </p>
<p>k: {k} </p>
<p>R^2: {R2} </p>
<p>σ: {sig}°</p>
<br>
<table>
<tr>
<td> <img src = "data:image/png;base64,{encodedOrgImg}" width = "250", height = "250" /></td>
<td> <img src ="data:image/png;base64,{encodedLogScl}" width = "250", height = "250"/></td>
</tr>
<tr>
<td> <img src = "data:image/png;base64,{encodedAngDist}" width = "250", height = "250" /></td>
<td> <img src = "data:image/png;base64,{encodedCartDist}" width = "250", height = "250" /></td>
</tr>
</table>
<p><br><br>
{date}
</p>
</body>
</html>
""".format(name=model.filename.stem, th=round(model.th, 2), k=round(model.k, 2), R2=round(model.R2, 2),
sig = round(model.sig[0], 2),
encodedOrgImg=model.orgImgEncoded.translate('bn\''),
encodedLogScl=model.logSclEncoded.translate('bn\''),
encodedAngDist=model.angDistEncoded.translate('bn\''),
encodedCartDist=model.cartDistEncoded.translate('bn\''),
date=model.timeStamp)
return html
@pyqtSlot(img_model.ImgModel)
def do_test(self, model):
"""
Makes report for an image that was active when user pressed Export button.
"""
self.webView.setHtml(self.createHtml(model, False))
self.document.setHtml(self.createHtml(model, True))
self.currentModel = model
self.show()
@pyqtSlot(list, list, OrderedSet, float, float, float, float)
def receiver(self, selectedImgs, dataList, imgList, uCut, lCut, radStep, angleInc):
"""
Received an information from FiberFit applicatin with necessary report data.
"""
self.dataList = dataList
self.list = selectedImgs
self.wholeList = imgList
self.uCut = uCut
self.lCut = lCut
self.radStep = radStep
self.angleInc = angleInc