本文整理汇总了Python中PyQt5.QtPrintSupport.QPrinter.setResolution方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.setResolution方法的具体用法?Python QPrinter.setResolution怎么用?Python QPrinter.setResolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtPrintSupport.QPrinter
的用法示例。
在下文中一共展示了QPrinter.setResolution方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calibration_pdf
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [as 别名]
def calibration_pdf(self, image):
printer = QPrinter()
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter)
printer.setResolution(600)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(self.get_path_to_calibration_file())
printer.setPageMargins(0,0,0,0,6)
painter = QPainter()
painter.begin(printer)
painter.drawImage(553,533, image)
font = QFont('Source Sans Pro', 10, QFont.Bold)
painter.setFont(font)
painter.drawText(254,277, _("Calibration sheet"))
font = QFont('Source Sans Pro', 7, QFont.Bold)
painter.setFont(font)
painter.drawText(600,2077, _("Instructions:"))
font = QFont('Source Sans Pro', 7, QFont.Normal)
painter.setFont(font)
painter.drawText(700, 2177, _("1. Place this paper on a flat and well iluminated surface."))
painter.drawText(700, 2277, _("2. Align your Revealer borderlines to the dashed lines on the top and left."))
painter.drawText(700, 2377, _("3. Press slightly the Revealer against the paper and read the numbers that best "
"match on the opposite sides. "))
painter.drawText(700, 2477, _("4. Type the numbers in the software"))
painter.end()
示例2: print_webpage
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [as 别名]
def print_webpage(self):
"""Print the webpage to a printer.
Callback for the print action.
Should show a print dialog and print the webpage to the printer.
"""
if self.print_settings.get("mode") == "high":
printer = QPrinter(mode=QPrinter.HighResolution)
else:
printer = QPrinter(mode=QPrinter.ScreenResolution)
if self.print_settings:
if self.print_settings.get("size_unit"):
try:
unit = getattr(
QPrinter,
self.print_settings.get("size_unit").capitalize()
)
except NameError:
debug(
"Specified print size unit '{}' not found,"
"using default.".format(
self.print_settings.get("size_unit")
))
unit = QPrinter.Millimeter
else:
unit = QPrinter.Millimeter
margins = (
list(self.print_settings.get("margins"))
or list(printer.getPageMargins(unit))
)
margins += [unit]
printer.setPageMargins(*margins)
if self.print_settings.get("orientation") == "landscape":
printer.setOrientation(QPrinter.Landscape)
else:
printer.setOrientation(QPrinter.Portrait)
if self.print_settings.get("paper_size"):
printer.setPaperSize(QSizeF(
*self.print_settings.get("paper_size")
), unit)
if self.print_settings.get("resolution"):
printer.setResolution(
int(self.print_settings.get("resolution"))
)
if not self.print_settings.get("silent"):
print_dialog = QPrintDialog(printer, self)
print_dialog.setWindowTitle("Print Page")
if not print_dialog.exec_() == QDialog.Accepted:
return False
self.print_(printer)
return True
示例3: toPdf
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [as 别名]
def toPdf(self, image, n=0):
printer = QPrinter()
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter);
printer.setResolution(600)
printer.setPageMargins(0,0,0,0, QPrinter.Millimeter)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(self.base_name+self.filename+'.pdf')
printer.setPageMargins(0,0,0,0,6)
painter = QPainter()
painter.begin(printer)
w = int(4958/13)
h = int(7017/13)
size_h = 2022+int(self.calibration_h)
size_v = 1274+int(self.calibration_v)
image = image.scaled(size_h, size_v)
for n in range(3):
painter.fillRect(0, (n*(7017/3)), 4958, 33, Qt.black )
painter.fillRect(0, (n*(7017/3))+3, 4958, 27, Qt.white )
painter.drawImage(553,(n*(7017/3))+533, image)
wpath = QPainterPath()
wpath.addRoundedRect(QRectF(548,(n*(7017/3))+528, size_h+5, size_v+5), 19, 19)
painter.setPen(QPen(Qt.black, 10))
painter.drawPath(wpath)
'''
master public key
qr_mpk = qrcode.make(self.mpk[0])#
painter.drawImage(3453,933, ImageQt(qr_mpk))
painter.setFont(QFont('Din Trek', 18, QFont.Black))
pen = QPen(Qt.black, 127)
painter.setPen(pen)
painter.fillRect(0, 133+(n*(7017/4)), w, 173, Qt.black )
painter.fillRect(0, 133+(n*(7017/4))+3, w-3, 167, Qt.white )
painter.drawText(177, 266 + (n*(7017/4)), 'R')
'''
painter.end()
示例4: print_sheet
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [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')
示例5: calibration_pdf
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [as 别名]
def calibration_pdf(self, image):
printer = QPrinter()
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter);
printer.setResolution(600)
printer.setPageMargins(0,0,0,0, QPrinter.Millimeter)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(self.base_dir+'calibration.pdf')
painter = QPainter()
painter.begin(printer)
image = image.scaled(self.size[0]*6.68,self.size[1]*6.68)
#tuning
font = QFont('Source Sans Pro', 27, QFont.Black)
painter.setFont(font)
cal_value = 0
for p in range (1,2):
for x in range (2):
for n in range(5):
cal_value+=1
painter.drawImage(254+(x*2296),130+(n*1326),image.scaled(2022+cal_value,1274+cal_value))
painter.drawText(354+(x*2296),270+(n*1326), str(cal_value))
printer.newPage()
painter.end()
示例6: toPdf
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [as 别名]
def toPdf(self, image):
printer = QPrinter()
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter)
printer.setResolution(600)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(self.get_path_to_revealer_file('.pdf'))
printer.setPageMargins(0,0,0,0,6)
painter = QPainter()
painter.begin(printer)
delta_h = round(image.width()/self.abstand_v)
delta_v = round(image.height()/self.abstand_h)
size_h = 2028+((int(self.calibration_h)*2028/(2028-(delta_h*2)+int(self.calibration_h)))/2)
size_v = 1284+((int(self.calibration_v)*1284/(1284-(delta_v*2)+int(self.calibration_v)))/2)
image = image.scaled(size_h, size_v)
painter.drawImage(553,533, image)
wpath = QPainterPath()
wpath.addRoundedRect(QRectF(553,533, size_h, size_v), 19, 19)
painter.setPen(QPen(Qt.black, 1))
painter.drawPath(wpath)
painter.end()
示例7: print_webpage
# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setResolution [as 别名]
def print_webpage(self):
"""Print the webpage to a printer.
Callback for the print action.
Should show a print dialog and print the webpage to the printer.
"""
print_settings = self.config.get("print_settings", {})
if print_settings.get("mode") == "high":
printer = QPrinter(mode=QPrinter.HighResolution)
else:
printer = QPrinter(mode=QPrinter.ScreenResolution)
# set which printer
# FIXME: This isn't documented, because it doesn't seem to work...
if print_settings.get("printer_name"):
debug(
"Setting printer to: {}".format(
print_settings.get("printer_name"))
)
printer.setPrinterName(print_settings.get("printer_name"))
debug("Printer is now: {}".format(printer.printerName()))
# Set the units
unit_name = print_settings.get("size_unit", 'Millimeter').title()
try:
unit = getattr(QPrinter, unit_name)
except AttributeError:
debug(
"Specified print size unit '{}' not found, using default."
.format(unit_name)
)
unit = QPrinter.Millimeter
# Set the margins
margins = list(
print_settings.get("margins", printer.getPageMargins(unit))
)
margins.append(unit)
printer.setPageMargins(*margins)
# Set the Orientation
orientation = print_settings.get("orientation", 'Portrait').title()
printer.setOrientation(
getattr(QPrinter, orientation, QPrinter.Portrait)
)
# Set the paper size
paper_size = print_settings.get("paper_size")
if type(paper_size) in (list, tuple):
# Assume it's a width/height spec
printer.setPaperSize(QSizeF(*paper_size), unit)
elif paper_size is not None: # Assume it's a size name
printer.setPaperSize(getattr(QPrinter, paper_size, 'AnsiA'))
# If paper_size is None, we just leave it at the printer's default
# Set the resolution
resolution = print_settings.get("resolution")
if resolution:
printer.setResolution(int(resolution))
# Show a print dialog, unless we want silent printing
if not print_settings.get("silent"):
print_dialog = QPrintDialog(printer, self)
print_dialog.setWindowTitle("Print Page")
if not print_dialog.exec_() == QDialog.Accepted:
return False
self.print_(printer)
return True