本文整理汇总了Python中PySide.QtGui.QPainter.viewport方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.viewport方法的具体用法?Python QPainter.viewport怎么用?Python QPainter.viewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainter
的用法示例。
在下文中一共展示了QPainter.viewport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import viewport [as 别名]
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
painter.save()
self.rect = painter.viewport()
self.rect.adjust(0, 0, -1, -1)
painter.drawRect(QRectF(self.rect))
self.prj.setupPrism(self.rect.height(), 68)
self.prj.setupProjectionMatrix(self.alef, self.bet)
# draw the prism
self.drawCubick(painter, [0, 0, 0], 63, 16)
mineCube = self.parent.presenter.mineCube
for y in range(len(mineCube)):
for z in range(len(mineCube[0])):
for x in range(len(mineCube[0][0])):
if mineCube[y][z][x] in self.parent.selectedMinerals.list_:
colo = self.parent.selectedMinerals.\
getColor(mineCube[y][z][x])
self.drawCubick(painter, [x, y, z], color=colo)
self.drawSliceCursor(painter, self.parent.presenter.elevation)
painter.restore()
painter.end()
del painter
示例2: Printer
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import viewport [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()