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


Python QPainter.Antialiasing方法代码示例

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


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

示例1: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 200)))
        painter.setPen(QPen(Qt.NoPen))

        if self.lists is not None:
            path = os.path.abspath(os.path.dirname(__file__)) + '/static/'
            path += self.lists[self.list_index] + '.png'
            self.list_index += 1
            if self.list_index >= len(self.lists):
                self.list_index = 0
            image = QImage(path)
            rect_image = image.rect()
            rect_painter = event.rect()
            dx = (rect_painter.width() - rect_image.width()) / 2.0
            dy = (rect_painter.height() - rect_image.height()) / 2.0
            painter.drawImage(dx, dy, image)

        painter.end() 
开发者ID:canard0328,项目名称:malss,代码行数:23,代码来源:waiting_animation.py

示例2: text_mousePressEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def text_mousePressEvent(self, e):
        if e.button() == Qt.LeftButton and self.current_pos is None:
            self.current_pos = e.pos()
            self.current_text = ""
            self.timer_event = self.text_timerEvent

        elif e.button() == Qt.LeftButton:

            self.timer_cleanup()
            # Draw the text to the image
            p = QPainter(self.pixmap())
            p.setRenderHints(QPainter.Antialiasing)
            font = build_font(self.config)
            p.setFont(font)
            pen = QPen(self.primary_color, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
            p.setPen(pen)
            p.drawText(self.current_pos, self.current_text)
            self.update()

            self.reset_mode()

        elif e.button() == Qt.RightButton and self.current_pos:
            self.reset_mode() 
开发者ID:learnpyqt,项目名称:15-minute-apps,代码行数:25,代码来源:paint.py

示例3: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, _):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        # 背景
        painter.fillRect(self.rect(), Qt.transparent)
        # 进度块
        ratio = (self.value() - self.minimum()) / \
            (self.maximum() - self.minimum())
        width = self.rect().width() * ratio
        if self.isError:
            color = QColor(self._failedColor or CLoadingBar.FailedColor)
        else:
            color = QColor(self._color or CLoadingBar.Color)
        color.setAlpha(self._alpha)
        painter.setBrush(color)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(QRectF(0, 0, width, self.height()), 2, 2) 
开发者ID:PyQt5,项目名称:CustomWidgets,代码行数:21,代码来源:CLoadingBar.py

示例4: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):
        ancho, altura = self.width(), self.height()
        icono = self.icono.scaled(ancho, altura, Qt.KeepAspectRatio, Qt.SmoothTransformation)

        pintor = QPainter()
        
        pintor.begin(self)
        pintor.setRenderHint(QPainter.Antialiasing, True)
        pintor.setPen(Qt.NoPen)
        pintor.drawPixmap(0, 0, icono, 0, 0, 0, 0)
        pintor.setPen(Qt.white)
        pintor.drawText(event.rect(), Qt.AlignCenter, self.etiqueta)
        pintor.setPen(Qt.NoPen)
        pintor.setBrush(self.opacidad)
        pintor.drawEllipse(0, 0, ancho, altura)
        pintor.end()

        self.setMask(icono.mask()) 
开发者ID:andresnino,项目名称:PyQt5,代码行数:20,代码来源:botonCircular.py

示例5: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):

        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255,255, 255, 127)))
        painter.setPen(QPen(QtCore.Qt.NoPen))

        for i in range(6):
            if (self.counter / 5) % 6 == i:
                painter.setBrush(QBrush(QColor(127 + (self.counter % 5) * 32, 0, 0)))
            else:
                painter.setBrush(QBrush(QColor(0, 0, 0)))
            painter.drawEllipse(
                self.width() / 2 + 30 * math.cos(2 * math.pi * i / 6.0) - 10,
                self.height() / 2 + 30 * math.sin(2 * math.pi * i / 6.0) - 10,
                20, 20)

        painter.end() 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:21,代码来源:loadf2.py

示例6: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):  # noqa: N802
        """We override the painting event to draw the invite ourselves."""
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        rect = QRect(self.rect())

        # Draw the border
        painter.setBrush(QBrush(QColor(122, 122, 122)))
        painter.setPen(Qt.NoPen)
        painter.drawRect(rect)

        rect.setX(rect.x() + 1)
        rect.setY(rect.y() + 1)
        rect.setWidth(rect.width() - 1)
        rect.setHeight(rect.height() - 1)

        # Draw the background
        painter.setBrush(QBrush(QColor(255, 255, 225)))
        painter.setPen(Qt.NoPen)
        painter.drawRect(rect) 
开发者ID:IDArlingTeam,项目名称:IDArling,代码行数:23,代码来源:invites.py

示例7: __init__

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)
        # 生成模拟数据
        self.m_dataTable = self.generateRandomData(3, 10, 7)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Scatter chart')
        # 添加Series
        self.getSeries(chart)
        # 创建默认xy轴
        chart.createDefaultAxes()
        chart.legend().setVisible(False) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:20,代码来源:ScatterChart.py

示例8: __init__

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def __init__(self, *args, **kwargs):
        super(ChartView, self).__init__(*args, **kwargs)
        self.resize(800, 600)
        self.setRenderHint(QPainter.Antialiasing)  # 抗锯齿
        # 自定义x轴label
        self.category = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
        self.initChart()

        # 提示widget
        self.toolTipWidget = GraphicsProxyWidget(self._chart)

        # line
        self.lineItem = QGraphicsLineItem(self._chart)
        pen = QPen(Qt.gray)
        pen.setWidth(1)
        self.lineItem.setPen(pen)
        self.lineItem.setZValue(998)
        self.lineItem.hide()

        # 一些固定计算,减少mouseMoveEvent中的计算量
        # 获取x和y轴的最小最大值
        axisX, axisY = self._chart.axisX(), self._chart.axisY()
        self.min_x, self.max_x = axisX.min(), axisX.max()
        self.min_y, self.max_y = axisY.min(), axisY.max() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:26,代码来源:LineStack.py

示例9: __init__

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Simple splinechart example')
        # 添加Series
        self.getSeries(chart)
        # 创建默认xy轴
        chart.createDefaultAxes()
        chart.legend().setVisible(False) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:18,代码来源:SplineChart.py

示例10: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):
        super(PercentProgressBar, self).paintEvent(event)
        width = self.width()
        height = self.height()
        side = min(width, height)

        painter = QPainter(self)
        # 反锯齿
        painter.setRenderHints(QPainter.Antialiasing |
                               QPainter.TextAntialiasing)
        # 坐标中心为中间点
        painter.translate(width / 2, height / 2)
        # 按照100x100缩放
        painter.scale(side / 100.0, side / 100.0)

        # 绘制中心园
        self._drawCircle(painter, 50)
        # 绘制圆弧
        self._drawArc(painter, 50 - self.BorderWidth / 2)
        # 绘制文字
        self._drawText(painter, 50) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:23,代码来源:PercentProgressBar.py

示例11: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):
        super(MetroCircleProgress, self).paintEvent(event)
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(self.rect(), self.BackgroundColor)
        painter.setPen(Qt.NoPen)

        for item, _ in self._items:
            painter.save()
            color = self.Color.toRgb()
            color.setAlphaF(item.opacity)
            painter.setBrush(color)
            # 5<= radius <=10
            radius = qBound(self.Radius, self.Radius / 200 *
                            self.height(), 2 * self.Radius)
            diameter = 2 * radius
            painter.drawRoundedRect(
                QRectF(
                    item.x / 100 * self.width() - diameter,
                    (self.height() - radius) / 2,
                    diameter, diameter
                ), radius, radius)
            painter.restore() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:25,代码来源:MetroCircleProgress.py

示例12: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):
        super(CircleProgressBar, self).paintEvent(event)
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.translate(self.width() / 2, self.height() / 2)
        side = min(self.width(), self.height())
        painter.scale(side / 100.0, side / 100.0)
        painter.rotate(self.angle)
        painter.save()
        painter.setPen(Qt.NoPen)
        color = self.Color.toRgb()
        for i in range(11):
            color.setAlphaF(1.0 * i / 10)
            painter.setBrush(color)
            painter.drawEllipse(30, -10, 20, 20)
            painter.rotate(36)
        painter.restore()
        self.angle += self.Delta if self.Clockwise else -self.Delta
        self.angle %= 360 
开发者ID:PyQt5,项目名称:PyQt,代码行数:21,代码来源:RoundProgressBar.py

示例13: __analysis

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def __analysis(self, datas):
        '''
        analysis json data
        :param datas: json data
        '''
        # 标题
        self.__setTitle(datas.get("title", None))
        # 抗锯齿
        if (datas.get("antialiasing", False) or False):
            self.setRenderHint(QPainter.Antialiasing)
        # 主题
        self._chart.setTheme(datas.get("theme", 0) or 0)
        # 动画
        self.__setAnimation(datas.get("animation", None))
        # 背景设置
        self.__setBackground(datas.get("background", None))
        # 边距设置
        self.__setMargins(datas.get("margins", None))
        # 设置图例
        self.__setLegend(datas.get("legend", None))
        # 设置series
        self.__setSeries(datas.get("series", None))
        # 自定义的x轴
        self.__setAxisX(datas.get("axisx", None))
        # 自定义的y轴 
开发者ID:PyQt5,项目名称:PyQt,代码行数:27,代码来源:ChartView.py

示例14: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def paintEvent(self, event):
        if not self.model().rowCount():
            self.show_drop_label()
            painter = QPainter(self.viewport())
            painter.setRenderHint(QPainter.Antialiasing)
            pen = QPen(QColor(128, 128, 128), 5)
            pen.setDashPattern([1, 2.91])
            painter.setPen(pen)
            geometry = self.geometry()
            painter.drawRect(
                geometry.x(),
                geometry.y() + self.dropzone_top_margin,
                geometry.width() - 24,
                geometry.height() - 24,
            )
        super().paintEvent(event) 
开发者ID:gridsync,项目名称:gridsync,代码行数:18,代码来源:view.py

示例15: setRoundMask

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import Antialiasing [as 别名]
def setRoundMask(self):
        bmp = QPixmap(self.size())
        bmp.fill(Qt.white)
        p = QPainter(bmp)
        p.setRenderHint(QPainter.Antialiasing)
        p.setBrush(QBrush(Qt.white))
        p.setCompositionMode(QPainter.CompositionMode_Clear)
        p.drawRoundedRect(0, 0, self.width(), self.height(), 3, 3)
        p.end()
        self.setMask(QRegion(QBitmap(bmp))) 
开发者ID:dragondjf,项目名称:QMusic,代码行数:12,代码来源:dquickview.py


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