QProgressBar进度条样式
This commit is contained in:
parent
8d3c406bfe
commit
53962a9d1e
6 changed files with 121 additions and 1 deletions
|
@ -33,6 +33,7 @@ encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/cr
|
||||||
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/information.py=utf-8
|
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/information.py=utf-8
|
||||||
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/question.py=utf-8
|
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/question.py=utf-8
|
||||||
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/warning.py=utf-8
|
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/warning.py=utf-8
|
||||||
|
encoding//\u754C\u9762\u7F8E\u5316/QSS\u7F8E\u5316\u4F8B\u5B50/QProgressBar\u8FDB\u5EA6\u6761\u6837\u5F0F/ProgressBar.py=utf-8
|
||||||
encoding//\u754C\u9762\u7F8E\u5316/QSS\u7F8E\u5316\u4F8B\u5B50/QPushButton\u6309\u94AE/ButtonHover.py=utf-8
|
encoding//\u754C\u9762\u7F8E\u5316/QSS\u7F8E\u5316\u4F8B\u5B50/QPushButton\u6309\u94AE/ButtonHover.py=utf-8
|
||||||
encoding//\u754C\u9762\u7F8E\u5316/QScrollBar\u6EDA\u52A8\u6761\u6837\u5F0F/ScrollBar.py=utf-8
|
encoding//\u754C\u9762\u7F8E\u5316/QScrollBar\u6EDA\u52A8\u6761\u6837\u5F0F/ScrollBar.py=utf-8
|
||||||
encoding//\u7A0B\u5E8F\u91CD\u542F/AutoRestart.py=utf-8
|
encoding//\u7A0B\u5E8F\u91CD\u542F/AutoRestart.py=utf-8
|
||||||
|
|
105
界面美化/QSS美化例子/QProgressBar进度条样式/ProgressBar.py
Normal file
105
界面美化/QSS美化例子/QProgressBar进度条样式/ProgressBar.py
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
'''
|
||||||
|
Created on 2018年1月30日
|
||||||
|
@author: Irony."[讽刺]
|
||||||
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
|
@email: 892768447@qq.com
|
||||||
|
@file: ProgressBar
|
||||||
|
@description:
|
||||||
|
'''
|
||||||
|
from random import randint
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from PyQt5.QtCore import QTimer
|
||||||
|
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QProgressBar
|
||||||
|
|
||||||
|
|
||||||
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
|
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 ProgressBar(QProgressBar):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(ProgressBar, self).__init__(*args, **kwargs)
|
||||||
|
self.setValue(0)
|
||||||
|
if self.minimum() != self.maximum():
|
||||||
|
self.timer = QTimer(self, timeout=self.onTimeout)
|
||||||
|
self.timer.start(randint(1, 3) * 1000)
|
||||||
|
|
||||||
|
def onTimeout(self):
|
||||||
|
if self.value() >= 100:
|
||||||
|
self.timer.stop()
|
||||||
|
self.timer.deleteLater()
|
||||||
|
del self.timer
|
||||||
|
return
|
||||||
|
self.setValue(self.value() + 1)
|
||||||
|
|
||||||
|
|
||||||
|
class Window(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(Window, self).__init__(*args, **kwargs)
|
||||||
|
self.resize(800, 600)
|
||||||
|
layout = QVBoxLayout(self)
|
||||||
|
layout.addWidget(
|
||||||
|
ProgressBar(self, minimum=0, maximum=100, objectName="RedProgressBar"))
|
||||||
|
layout.addWidget( # 繁忙状态
|
||||||
|
ProgressBar(self, minimum=0, maximum=0, objectName="RedProgressBar"))
|
||||||
|
|
||||||
|
layout.addWidget(
|
||||||
|
ProgressBar(self, minimum=0, maximum=100, textVisible=False,
|
||||||
|
objectName="GreenProgressBar"))
|
||||||
|
layout.addWidget(
|
||||||
|
ProgressBar(self, minimum=0, maximum=0, textVisible=False,
|
||||||
|
objectName="GreenProgressBar"))
|
||||||
|
|
||||||
|
layout.addWidget(
|
||||||
|
ProgressBar(self, minimum=0, maximum=100, textVisible=False,
|
||||||
|
objectName="BlueProgressBar"))
|
||||||
|
layout.addWidget(
|
||||||
|
ProgressBar(self, minimum=0, maximum=0, textVisible=False,
|
||||||
|
objectName="BlueProgressBar"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
app.setStyleSheet(StyleSheet)
|
||||||
|
w = Window()
|
||||||
|
w.show()
|
||||||
|
sys.exit(app.exec_())
|
10
界面美化/QSS美化例子/QProgressBar进度条样式/README.md
Normal file
10
界面美化/QSS美化例子/QProgressBar进度条样式/README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# QProgressBar进度条 QSS 美化样式
|
||||||
|
|
||||||
|
主要改变背景颜色、高度、边框、块颜色、边框、圆角
|
||||||
|
|
||||||
|
详细美化都在代码里的QSS中注释了
|
||||||
|
|
||||||
|
效果图:
|
||||||
|
|
||||||
|
### [ProgressBar.py](ProgressBar.py)
|
||||||
|
![ProgressBar](ScreenShot/ProgressBar.gif)
|
BIN
界面美化/QSS美化例子/QProgressBar进度条样式/ScreenShot/ProgressBar.gif
Normal file
BIN
界面美化/QSS美化例子/QProgressBar进度条样式/ScreenShot/ProgressBar.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
|
@ -4,4 +4,7 @@
|
||||||
- [1.1 QPushButton 颜色及圆角](QPushButton按钮/ButtonHover.py)
|
- [1.1 QPushButton 颜色及圆角](QPushButton按钮/ButtonHover.py)
|
||||||
|
|
||||||
### [2.QCalendarWidget](QCalendarWidget日历/)
|
### [2.QCalendarWidget](QCalendarWidget日历/)
|
||||||
- [2.1 QCalendarWidget日历样式](QCalendarWidget日历/CalendarWidget.py)
|
- [2.1 QCalendarWidget日历样式](QCalendarWidget日历/CalendarWidget.py)
|
||||||
|
|
||||||
|
### [3.QProgressBar](QProgressBar进度条样式/)
|
||||||
|
- [3.1 QProgressBar进度条样式](QProgressBar进度条样式/ProgressBar.py)
|
|
@ -3,6 +3,7 @@
|
||||||
### [1.QSS美化例子](QSS美化例子/)
|
### [1.QSS美化例子](QSS美化例子/)
|
||||||
- [1.1 QPushButton按钮](QSS美化例子/QPushButton按钮/)
|
- [1.1 QPushButton按钮](QSS美化例子/QPushButton按钮/)
|
||||||
- [1.2 QCalendarWidget日历](QSS美化例子/QCalendarWidget日历/)
|
- [1.2 QCalendarWidget日历](QSS美化例子/QCalendarWidget日历/)
|
||||||
|
- [1.3 QProgressBar进度条样式](QSS美化例子/QProgressBar进度条样式/)
|
||||||
|
|
||||||
### [2.QMessageBox样式](QMessageBox样式/)
|
### [2.QMessageBox样式](QMessageBox样式/)
|
||||||
- [2.1 方案一](QMessageBox样式/方案一)
|
- [2.1 方案一](QMessageBox样式/方案一)
|
||||||
|
|
Loading…
Reference in a new issue