本文整理汇总了Python中PySide.QtGui.QPainter.setViewport方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.setViewport方法的具体用法?Python QPainter.setViewport怎么用?Python QPainter.setViewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainter
的用法示例。
在下文中一共展示了QPainter.setViewport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setViewport [as 别名]
def paintEvent(self, event):
"""
Handles the ``paintEvent`` event for :class:`ImageWidget`.
:param `event`: A `QPaintEvent`_ to be processed.
"""
painter = QPainter(self)
img = self.img
width, height = img.width(), img.height()
painter.setViewport(0, 0, width, height)
painter.setWindow(0, 0, width, height)
painter.drawImage(0, 0, img)
示例2: Printer
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setViewport [as 别名]
#.........这里部分代码省略.........
def emit_tps_report(self, employees):
html = """
<img
style="float: left;"
src=":/img/mmt.png"
width="200"
height="65">
<h1 align="right">TPS Report<br /> </h1>
<hr />
"""
html += self.generate_sorted_employee_table(employees)
self.make_page(html)
def emit_sorted_employees(self, employees):
html = """
<img
style="float: left;"
src=":/img/mmt.png"
width="200"
height="65">
<h1 align="right">All Employees sorted by Evalation Score<br />(highest to lowest)</h1>
<hr />
<table
align="center"
cellspacing="10">
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
<th>Phone Number</th>
<th>Cell Number</th>
<th>Overall Score</th>
</tr>
"""
for employer, employee, score, comments in employees:
html += """
<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>
""" % (employee["id"],
employee["first_name"],
employee["last_name"],
employee["email_address"],
employee["phone_number"],
employee["cell_number"],
score)
html += "</table>"
self.make_page(html)
def paper_mode(self):
self.handler.setOutputFormat(QPrinter.NativeFormat)
self.handler.setOutputFileName("")
def pdf_mode(self, file_name):
self.handler.setOutputFormat(QPrinter.PdfFormat)
self.handler.setOutputFileName(file_name)
def run(self):
page_num = 1
last_page = len(self.pages)
self.painter = QPainter(self.handler)
for page in self.pages:
width = self.painter.viewport().width()
height = self.painter.viewport().height()
rect = QRect(0, 0, width, height)
self.painter.save()
self.painter.setViewport(rect)
page.setTextWidth(width)
page.drawContents(self.painter)
self.painter.restore()
if page_num != last_page:
self.handler.newPage()
page_num += 1
self.painter.end()
self.reset()