12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- '''
- @文件 :troublebar.py
- @时间 :2022/01/22 10:06:04
- @作者 :None
- @版本 :1.0
- @说明 :故障主题
- '''
- from utils.qt import QProgressBar, QPainter
- # from random import randint
- StyleSheet = """
- /*设置红色进度条*/
- #RedProgressBar {
- text-align: center; /*进度值居中*/
- }
- #RedProgressBar::chunk {
- background-color: #F44336;
- }
- #GreenProgressBar {
- min-height: 12px;
- max-height: 12px;
- border-radius: 6px;
- }
- #GreenProgressBar::chunk {
- border-radius: 6px;
- background-color: #009688;
- }
- #BlueProgressBar {
- border: 2px solid #2196F3;/*边框以及边框颜色*/
- border-radius: 5px;
- background-color: #E0E0E0;
- }
- BlueProgressBar::chunk {
- background-color: #2196F3;
- width: 10px; /*区块宽度*/
- margin: 0.5px;
- }
- """
- class TroubleProgressBar(QProgressBar):
- def __init__(self, parent=None):
- super(TroubleProgressBar, self).__init__(parent)
- self.setTextVisible(False)
- self.setStyleSheet("QProgressBar::chunk{background:qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0.0 green, stop: 0 yellow, stop: 1 red)}")
- def paintEvent(self, event):
- """绘制按钮"""
- super(TroubleProgressBar, self).paintEvent(event)
- # 绘制准备工作,启用反锯齿
- # 创建绘制器并设置抗锯齿和图片流畅转换
- painter = QPainter(self)
- painter.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing)
|