本文整理汇总了Python中PyQt4.QtGui.QPrinter.logicalDpiX方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.logicalDpiX方法的具体用法?Python QPrinter.logicalDpiX怎么用?Python QPrinter.logicalDpiX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPrinter
的用法示例。
在下文中一共展示了QPrinter.logicalDpiX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotPDF
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import logicalDpiX [as 别名]
def plotPDF(self, width, height, output_file, units = "pixels", _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. The optional units argument specifies the units
used to measure the plot size; by default, pixels are used, but "cm",
"mm" and "in" are also acceptable.
Returns the QPrinter object used to write the file."""
pdf = QPrinter()
pdf.setOutputFormat(QPrinter.PdfFormat)
pdf.setOutputFileName(output_file)
if units == "in":
width = pdf.logicalDpiX() * width
height = pdf.logicalDpiY() * height
elif units == "cm":
width = pdf.logicalDpiX() * (width / 2.54)
height = pdf.logicalDpiY() * (height / 2.54)
elif units == "mm":
width = pdf.logicalDpiX() * (width / 25.4)
height = pdf.logicalDpiY() * (height / 25.4)
elif units != "pixels":
raise BDianaError, "Unknown units specified to plotPDF: %s" % units
pdf.setPaperSize(QSizeF(width, height), QPrinter.DevicePixel)
pdf.setFullPage(True)
return self._plot(width, height, pdf, _plotting_object)[0]