當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。