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


Python QPainter.setRenderHint方法代码示例

本文整理汇总了Python中PyQt5.Qt.QPainter.setRenderHint方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.setRenderHint方法的具体用法?Python QPainter.setRenderHint怎么用?Python QPainter.setRenderHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.Qt.QPainter的用法示例。


在下文中一共展示了QPainter.setRenderHint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
    def save(self, filename, chart_size, legend_width=None):
        """ save graph as file
        """
        if not filename:
            """ if filename is not specified, open a save file dialog
            """
            filename = QFileDialog.getSaveFileName(None, 'Save File')[0]
            if not filename[-4:] in ['.png', '.jpg',]:
                """ TODO : cleaner extension manager
                """
                filename += ".png"
                
        image_size = chart_size
        
        if legend_width:
            image_size = image_size + QSize(legend_width, 0)

        image = QImage(image_size, QImage.Format_ARGB32_Premultiplied)
        painter = QPainter(image)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(image.rect(), Qt.white)
        self.draw(painter, QRect(QPoint(0, 0), chart_size))
        
        if legend_width:
            legendRect = QRect(QPoint(chart_size.width(), 10),
                               QSize(legend_width, chart_size.height()))
            self.draw_legend(painter, legendRect)
        painter.end()
        return image.save(filename)
开发者ID:maxdesp,项目名称:PyQtCharts,代码行数:31,代码来源:qcharts.py

示例2: __call__

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
 def __call__(self, canvas):
     if canvas.has_selection and canvas.selection_state.rect is not None:
         pimg = self.after_image
         img = self.after_image = QImage(canvas.current_image)
         rect = QRectF(*get_selection_rect(img, canvas.selection_state.rect, canvas.target))
         p = QPainter(img)
         p.setRenderHint(p.SmoothPixmapTransform, True)
         p.drawImage(rect, pimg, QRectF(pimg.rect()))
         p.end()
     return self.after_image
开发者ID:Ralnoc,项目名称:calibre,代码行数:12,代码来源:canvas.py

示例3: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
 def paintEvent(self, ev):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.TextAntialiasing)
     f = painter.font()
     f.setBold(True)
     f.setPixelSize(self.height() - 1)
     painter.setFont(f)
     painter.setPen(QColor('red' if self.is_enabled else 'green'))
     painter.drawText(self.rect(), Qt.AlignCenter, 'Z')
     painter.end()
开发者ID:kovidgoyal,项目名称:vise,代码行数:12,代码来源:status_bar.py

示例4: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
    def paintEvent(self, event):
        w = self.viewport().rect().width()
        painter = QPainter(self.viewport())
        painter.setClipRect(event.rect())
        floor = event.rect().bottom()
        ceiling = event.rect().top()
        fv = self.firstVisibleBlock().blockNumber()
        origin = self.contentOffset()
        doc = self.document()
        lines = []

        for num, text in self.headers:
            top, bot = num, num + 3
            if bot < fv:
                continue
            y_top = self.blockBoundingGeometry(doc.findBlockByNumber(top)).translated(origin).y()
            y_bot = self.blockBoundingGeometry(doc.findBlockByNumber(bot)).translated(origin).y()
            if max(y_top, y_bot) < ceiling:
                continue
            if min(y_top, y_bot) > floor:
                break
            painter.setFont(self.heading_font)
            br = painter.drawText(3, y_top, w, y_bot - y_top - 5, Qt.TextSingleLine, text)
            painter.setPen(QPen(self.palette().text(), 2))
            painter.drawLine(0, br.bottom()+3, w, br.bottom()+3)

        for top, bot, kind in self.changes:
            if bot < fv:
                continue
            y_top = self.blockBoundingGeometry(doc.findBlockByNumber(top)).translated(origin).y()
            y_bot = self.blockBoundingGeometry(doc.findBlockByNumber(bot)).translated(origin).y()
            if max(y_top, y_bot) < ceiling:
                continue
            if min(y_top, y_bot) > floor:
                break
            if y_top != y_bot:
                painter.fillRect(0,  y_top, w, y_bot - y_top, self.diff_backgrounds[kind])
            lines.append((y_top, y_bot, kind))
            if top in self.images:
                img, maxw = self.images[top][:2]
                if bot > top + 1 and not img.isNull():
                    y_top = self.blockBoundingGeometry(doc.findBlockByNumber(top+1)).translated(origin).y() + 3
                    y_bot -= 3
                    scaled, imgw, imgh = fit_image(img.width(), img.height(), w - 3, y_bot - y_top)
                    painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
                    painter.drawPixmap(QRect(3, y_top, imgw, imgh), img)

        painter.end()
        PlainTextEdit.paintEvent(self, event)
        painter = QPainter(self.viewport())
        painter.setClipRect(event.rect())
        for top, bottom, kind in sorted(lines, key=lambda (t, b, k):{'replace':0}.get(k, 1)):
            painter.setPen(QPen(self.diff_foregrounds[kind], 1))
            painter.drawLine(0, top, w, top)
            painter.drawLine(0, bottom - 1, w, bottom - 1)
开发者ID:AtulKumar2,项目名称:calibre,代码行数:57,代码来源:view.py

示例5: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
 def paintEvent(self, ev):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing, True)
     painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
     try:
         self.paint_background(painter)
     except Exception:
         pass
     finally:
         painter.end()
     QWidget.paintEvent(self, ev)
开发者ID:kovidgoyal,项目名称:vise,代码行数:13,代码来源:popup.py

示例6: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
 def paintEvent(self, ev):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing, True)
     painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
     try:
         if self.rendered_pixmap is None:
             self.paint_background(painter)
         else:
             self.animated_paint(painter)
     finally:
         painter.end()
开发者ID:j-howell,项目名称:calibre,代码行数:13,代码来源:proceed.py

示例7: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
 def paintEvent(self, ev):
     if self.timer.isActive():
         if not self.errored_out:
             try:
                 draw_snake_spinner(QPainter(self), self.rect(), self.angle, self.light, self.dark)
             except Exception:
                 import traceback
                 traceback.print_exc()
                 self.errored_out = True
     else:
         r = self.rect()
         painter = QPainter(self)
         painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
         icon = downloads_icon()
         pmap = icon.pixmap(r.width(), r.height())
         x = (r.width() - int(pmap.width() / pmap.devicePixelRatio())) // 2
         y = (r.height() - int(pmap.height() / pmap.devicePixelRatio())) // 2 + 1
         painter.drawPixmap(x, y, pmap)
开发者ID:kovidgoyal,项目名称:vise,代码行数:20,代码来源:downloads.py

示例8: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import setRenderHint [as 别名]
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
    
        if self.graph :
            graphRect  = QRect(0,
                               0,
                               event.rect().width() - 120,
                               event.rect().height())
                                     
            legendRect = QRect(event.rect().width() - 120,
                               20,
                               120,
                               event.rect().height() - 20)

            self.graph.draw(painter, graphRect)
            self.graph.draw_legend(painter, legendRect)

        painter.end()
开发者ID:maxdesp,项目名称:PyQtCharts,代码行数:21,代码来源:qcharts.py


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