当前位置: 首页>>代码示例>>Python>>正文


Python QPainter.viewport方法代码示例

本文整理汇总了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
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:30,代码来源:__init__.py

示例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()
开发者ID:xiphffff,项目名称:Caerus,代码行数:104,代码来源:printer.py


注:本文中的PySide.QtGui.QPainter.viewport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。