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


Python QtGui.QLinearGradient方法代码示例

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


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

示例1: paintEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def paintEvent(self, event):
        painter = QPainter(self)
        painter.setFont(self.font)
        
        linear = QLinearGradient(QPoint(self.rect().topLeft()), QPoint(self.rect().bottomLeft()))
        linear.setStart(0, 10)
        linear.setFinalStop(0, 50)
        linear.setColorAt(0.1, QColor(14, 179, 255));
        linear.setColorAt(0.5, QColor(154, 232, 255));
        linear.setColorAt(0.9, QColor(14, 179, 255));
        
        linear2 = QLinearGradient(QPoint(self.rect().topLeft()), QPoint(self.rect().bottomLeft()))
        linear2.setStart(0, 10)
        linear2.setFinalStop(0, 50)
        linear2.setColorAt(0.1, QColor(222, 54, 4));
        linear2.setColorAt(0.5, QColor(255, 172, 116));
        linear2.setColorAt(0.9, QColor(222, 54, 4));
        
        painter.setPen(QColor(0, 0, 0, 200));
        painter.drawText(QRect(1, 1, self.screen.width(), 60), Qt.AlignHCenter | Qt.AlignVCenter, self.lyric)
        
        painter.setPen(QColor('transparent'));
        self.textRect = painter.drawText(QRect(0, 0, self.screen.width(), 60), Qt.AlignHCenter | Qt.AlignVCenter, self.lyric)

        painter.setPen(QPen(linear, 0))
        painter.drawText(self.textRect, Qt.AlignLeft | Qt.AlignVCenter, self.lyric)
        if self.intervel != 0:
            self.widthBlock = self.textRect.width()/(self.intervel/150.0)
        else:
            self.widthBlock = 0
        self.maskRect = QRectF(self.textRect.x(), self.textRect.y(), self.textRect.width(), self.textRect.height())
        self.maskRect.setWidth(self.maskWidth)
        painter.setPen(QPen(linear2, 0));
        painter.drawText(self.maskRect, Qt.AlignLeft | Qt.AlignVCenter, self.lyric) 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:36,代码来源:player.py

示例2: initData

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def initData(self):
        self._hovered = False

        self.linear_gradient = QLinearGradient()
        self.linear_gradient.setStart(0, 10)
        self.linear_gradient.setFinalStop(0, 40)
    
        self.linear_gradient.setColorAt(0.1, QColor(14, 179, 255));
        self.linear_gradient.setColorAt(0.5, QColor(114, 232, 255));
        self.linear_gradient.setColorAt(1, QColor(14, 179, 255));

        self.mask_linear_gradient = QLinearGradient()
        self.mask_linear_gradient.setStart(0, 10)
        self.mask_linear_gradient.setFinalStop(0, 40)
        self.mask_linear_gradient.setColorAt(0.1, QColor(0, 100, 40))
        self.mask_linear_gradient.setColorAt(0.5, QColor(0, 72, 16))
        self.mask_linear_gradient.setColorAt(1, QColor(0, 255, 40))

        self.text = ""
        self.percentage = 0
        self.lyric_id = 0

        self.line1_text = ''
        self.line1_percentage = 0

        self.line2_text = ''
        self.line2_percentage = 0

        self.lrcfont = QFont()
        self.lrcfont.setPixelSize(30)
        self.setFont(self.lrcfont)

        self._lineMode = 1 
开发者ID:dragondjf,项目名称:QMusic,代码行数:35,代码来源:lrcwindow.py

示例3: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def __init__(self, parent):
        super().__init__(parent)

        db_range = abs(self.DB_MIN - self.DB_MAX)
        yellow = abs(self.DB_MIN + 20) / db_range  # -20 db
        red = abs(self.DB_MIN) / db_range          # 0 db

        self.grad = QLinearGradient()
        self.grad.setColorAt(0, QColor(0, 255, 0))            # Green
        self.grad.setColorAt(yellow, QColor(255, 255, 0))     # Yellow
        self.grad.setColorAt(red, QColor(255, 0, 0))          # Red

        self.reset() 
开发者ID:FrancescoCeruti,项目名称:linux-show-player,代码行数:15,代码来源:qdbmeter.py

示例4: _draw_pixmap_overlay

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def _draw_pixmap_overlay(self, painter, draw_width, draw_height, scrolled):
        painter.save()
        rect = QRect(0, 0, draw_width, draw_height)
        painter.translate(0, -scrolled)
        gradient = QLinearGradient(rect.topLeft(), rect.bottomLeft())
        color = self.palette().color(QPalette.Base)
        if draw_height == self.height():
            gradient.setColorAt(0, add_alpha(color, 180))
            gradient.setColorAt(1, add_alpha(color, 230))
        else:
            if self._app.theme_mgr.theme == Light:
                gradient.setColorAt(0, add_alpha(color, 220))
                gradient.setColorAt(0.1, add_alpha(color, 180))
                gradient.setColorAt(0.2, add_alpha(color, 140))
                gradient.setColorAt(0.6, add_alpha(color, 140))
                gradient.setColorAt(0.8, add_alpha(color, 200))
                gradient.setColorAt(0.9, add_alpha(color, 240))
                gradient.setColorAt(1, color)
            else:
                gradient.setColorAt(0, add_alpha(color, 50))
                gradient.setColorAt(0.6, add_alpha(color, 100))
                gradient.setColorAt(0.8, add_alpha(color, 200))
                gradient.setColorAt(0.9, add_alpha(color, 240))
                gradient.setColorAt(1, color)
        painter.setBrush(gradient)
        painter.drawRect(rect)
        painter.restore() 
开发者ID:feeluown,项目名称:FeelUOwn,代码行数:29,代码来源:right_panel.py

示例5: _draw_overlay

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def _draw_overlay(self, painter, draw_width, draw_height, scrolled):
        painter.save()
        rect = QRect(0, 0, draw_width, draw_height)
        painter.translate(0, -scrolled)
        gradient = QLinearGradient(rect.topLeft(), rect.bottomLeft())
        gradient.setColorAt(0, self.palette().color(QPalette.Window))
        gradient.setColorAt(1, self.palette().color(QPalette.Base))
        painter.setBrush(gradient)
        painter.drawRect(rect)
        painter.restore() 
开发者ID:feeluown,项目名称:FeelUOwn,代码行数:12,代码来源:right_panel.py

示例6: getSeries

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def getSeries(self):
        # 创建Series
        series0 = QLineSeries(self)
        series1 = QLineSeries(self)

        # 添加数据
        series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) \
                << QPointF(12, 6) << QPointF(16, 7) << QPointF(18, 5)
        series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) \
                << QPointF(12, 3) << QPointF(16, 4) << QPointF(18, 3)

        # 创建区域图
        series = QAreaSeries(series0, series1)
        series.setName('Batman')

        # 画笔
        pen = QPen(0x059605)
        pen.setWidth(3)
        series.setPen(pen)

        # 设置画刷
        gradient = QLinearGradient(QPointF(0, 0), QPointF(0, 1))
        gradient.setColorAt(0.0, QColor(0x3cc63c))
        gradient.setColorAt(1.0, QColor(0x26f626))
        gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
        series.setBrush(gradient)

        return series 
开发者ID:PyQt5,项目名称:PyQt,代码行数:30,代码来源:AreaChart.py

示例7: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def __init__(self):
        super(DQuickWidget, self).__init__()
        self.resize(1000, 100)

        self.setMinimumSize(100, 80)

        self.linear_gradient = QLinearGradient()
        self.linear_gradient.setStart(0, 10)
        self.linear_gradient.setFinalStop(0, 40)
    
        self.linear_gradient.setColorAt(0.1, QColor(14, 179, 255));
        self.linear_gradient.setColorAt(0.5, QColor(114, 232, 255));
        self.linear_gradient.setColorAt(0.9, QColor(14, 179, 255));

        self.mask_linear_gradient = QLinearGradient()
        self.mask_linear_gradient.setStart(0, 10)
        self.mask_linear_gradient.setFinalStop(0, 40)
        self.mask_linear_gradient.setColorAt(0.1, QColor(222, 54, 4))
        self.mask_linear_gradient.setColorAt(0.5, QColor(255, 72, 16))
        self.mask_linear_gradient.setColorAt(0.9, QColor(222, 54, 4))

        self.text = "PyQt 5.2版本最新发布了,Qt 库的Python绑定"

        self.font = QFont()
        self.font.setFamily("Times New Roman")
        self.font.setBold(True)
        self.font.setPixelSize(30)

        self.setFont(self.font)

        self.timer = QTimer(self)
        self.timer.setInterval(100)
        self.timer.timeout.connect(self.update)
        self.timer.start()

        self.textWidth = self.fontMetrics().width(self.text)
        self.textHeight = self.fontMetrics().height()

        self.p = 0.1

        self.button = QPushButton('1111', self)
        self.button.move(100, 0)
        self.button.resize(40, 40)

        self.toolBarHeight = 50 
开发者ID:dragondjf,项目名称:QMusic,代码行数:47,代码来源:lrcwindow.py

示例8: add_new_breathing_rect

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QLinearGradient [as 别名]
def add_new_breathing_rect(self, i_io: mc.mc_global.BreathingState, i_length: int=1):
        if i_io == mc.mc_global.BreathingState.breathing_out:
            self.new_cycle_bool = False

        # Rectangle
        xpos_ft = 0.0
        if len(self.in_breath_graphics_qgri_list) > 0:
            margin_int = SMALL_MARGIN_FT
            if self.new_cycle_bool:
                margin_int = LARGE_MARGIN_FT
            last_graphics_rect_item = self.in_breath_graphics_qgri_list[-1]
            xpos_ft = float(last_graphics_rect_item.rect().right() + margin_int)
            if i_io == mc.mc_global.BreathingState.breathing_out:
                xpos_ft = float(last_graphics_rect_item.rect().left())
        ypos_ft = -i_length
        if i_io == mc.mc_global.BreathingState.breathing_out:
            ypos_ft = 0.0

        t_drawrect = QtCore.QRectF(xpos_ft, ypos_ft, BAR_WIDTH_FT, i_length)

        # Gradient
        x_gradient = t_drawrect.x() - GRADIENT_IN_FT
        if i_io == mc.mc_global.BreathingState.breathing_out:
            x_gradient = t_drawrect.x() + GRADIENT_OUT_FT
        t_start_qpointf = QtCore.QPointF(x_gradient, t_drawrect.y())
        t_stop_qpointf = t_drawrect.bottomRight()
        t_linear_gradient = QtGui.QLinearGradient(t_start_qpointf, t_stop_qpointf)
        if i_io == mc.mc_global.BreathingState.breathing_in:
            t_linear_gradient.setColorAt(0.0, QtGui.QColor(0, 153, 0))
            t_linear_gradient.setColorAt(1.0, QtGui.QColor(0, 204, 0))
        else:
            t_linear_gradient.setColorAt(0.0, QtGui.QColor(51, 255, 51))
            t_linear_gradient.setColorAt(1.0, QtGui.QColor(102, 255, 102))

        # Adding rectangle with gradient
        t_graphics_rect_item = self.breathing_graphicsscene.addRect(
            t_drawrect,
            pen=QtGui.QPen(QtCore.Qt.NoPen),
            brush=QtGui.QBrush(t_linear_gradient)
        )
        if i_io == mc.mc_global.BreathingState.breathing_in:
            self.in_breath_graphics_qgri_list.append(t_graphics_rect_item)
        elif i_io == mc.mc_global.BreathingState.breathing_out:
            self.out_breath_graphics_qgri_list.append(t_graphics_rect_item)
        # -an alternative to storing this separately might be to use ".items" and check for type
        #  as there is a QGraphicsRectItem
        # -another alternative: **http://doc.qt.io/qt-5/qgraphicsitem.html#type** 
开发者ID:mindfulness-at-the-computer,项目名称:mindfulness-at-the-computer,代码行数:49,代码来源:breathing_history_wt.py


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