整理美化部分目录

This commit is contained in:
Irony 2018-11-01 00:10:21 +08:00
parent 9f39570899
commit 298f97d33c
110 changed files with 1459 additions and 1514 deletions

View file

@ -65,37 +65,13 @@ encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/\u4EFF
encoding//\u591A\u9875\u9762/QStackedWidget/\u5DE6\u4FA7\u9009\u9879\u5361/\u5DE6\u4FA7\u9009\u9879\u5361.py=utf-8
encoding//\u6811\u7ED3\u6784/QTreeWidget/Json\u751F\u6210QTreeWidget/Json\u751F\u6210\u6811\u5F62\u7ED3\u6784.py=utf-8
encoding//\u6D4F\u89C8\u5668/QWebView/\u68A6\u5E7B\u6811/DreamTree.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QFileSystemModel\u56FE\u6807/FileSystemModel.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QLabel\u5706\u5F62\u5934\u50CF/CircleLabel.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/critical.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/information.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/question.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/warning.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/critical.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/warning.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QPushButton\u8FDB\u5EA6\u52A8\u753B/PushButtonFont.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QPushButton\u8FDB\u5EA6\u52A8\u753B/PushButtonLine.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/QScrollBar\u6EDA\u52A8\u6761\u6837\u5F0F/ScrollBar.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QSlider\u7F8E\u5316/PaintQSlider.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QSlider\u7F8E\u5316/QssQSlider.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/CircleProgressBar.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/MetroCircleProgress.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/MetroLineProgress.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/PercentProgressBar.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u6C34\u6CE2\u7EB9\u8FDB\u5EA6\u6761/ProgressBar.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u6C34\u6CE2\u7EB9\u8FDB\u5EA6\u6761/TestWidget.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u8FB9\u6846\u52A8\u753B\u9634\u5F71/AnimationShadowEffect.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/\u8FB9\u6846\u52A8\u753B\u9634\u5F71/Test.py=utf-8
encoding//\u7A97\u53E3/\u5206\u5272\u7A97\u53E3\u7684\u5206\u5272\u6761\u91CD\u5199.py=utf-8
encoding//\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3/FramelessWindow.py=utf-8
encoding//\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3/win\u65E0\u8FB9\u6846\u8C03\u6574\u5927\u5C0F.py=utf-8
encoding//\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3.py=utf-8
encoding//\u7A97\u53E3/\u6D88\u606F\u5BF9\u8BDD\u6846\u5012\u8BA1\u65F6\u5173\u95ED.py=utf-8
encoding//\u7A97\u53E3/\u7A97\u53E3\u91CD\u542F.py=utf-8
encoding//\u7F8E\u5316/QLabel/\u5706\u5F62\u56FE\u7247.py=utf-8
encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/CustomPaintWidget.py=utf-8
encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/CustomWidget.py=utf-8
encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/test.py=utf-8

View file

@ -1,10 +0,0 @@
# QLabel圆形头像
一种比较好的方法制作圆形头像
### 简单说明
该方法使用QPainter的 setClipPath 方法结合QPainterPath对图片进行裁剪。
截图
![1](ScreenShot/1.png)

View file

@ -1,10 +0,0 @@
# QPushButton 加载动画
### 简单说明
- 1.第一种是利用字体使用FontAwesome字体来显示一个圆形进度条然后利用旋转动画
- 2.第二种是在按钮下方画一条线,根据百分值绘制
截图
![1](ScreenShot/1.gif)
![1](ScreenShot/2.gif)

View file

@ -1,8 +0,0 @@
# QPushButton 按钮 QSS 美化样式
主要改变背景颜色、鼠标按下颜色、鼠标悬停颜色、圆角、圆形、文字颜色
效果图:
### [ButtonHover.py](ButtonHover.py)
![ButtonHover](ScreenShot/ButtonHover.gif)

View file

@ -1,10 +0,0 @@
# 通过QSS对控件进行美化
### [1.QPushButton](QPushButton按钮/)
- [1.1 QPushButton 颜色及圆角](QPushButton按钮/ButtonHover.py)
### [2.QCalendarWidget](QCalendarWidget日历/)
- [2.1 QCalendarWidget日历样式](QCalendarWidget日历/CalendarWidget.py)
### [3.QProgressBar](QProgressBar进度条样式/)
- [3.1 QProgressBar进度条样式](QProgressBar进度条样式/ProgressBar.py)

View file

@ -1,24 +0,0 @@
# 通过QSS或者重绘对界面进行美化
### [1.QSS美化例子](QSS美化例子/)
- [1.1 QPushButton按钮](QSS美化例子/QPushButton按钮/)
- [1.2 QCalendarWidget日历](QSS美化例子/QCalendarWidget日历/)
- [1.3 QProgressBar进度条样式](QSS美化例子/QProgressBar进度条样式/)
### [2.Material样式](https://github.com/892768447/QMaterial)
### [3.QMessageBox样式](QMessageBox样式/)
- [3.1 方案一](QMessageBox样式/方案一)
- [3.2 方案二](QMessageBox样式/方案二)
### [4.QScrollBar滚动条样式](QScrollBar滚动条样式/)
### [5.QLabel圆形头像](QLabel圆形头像/)
### [6.QFileSystemModel图标](QFileSystemModel图标/)
### [7.QPushButton进度动画](QPushButton进度动画/)
### [7.水波纹进度条](水波纹进度条/)
### [8.各类进度条](各类进度条/)

View file

@ -1,117 +1,117 @@
'''
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: CalendarWidget
@description: 日历
'''
import sys
from PyQt5.QtWidgets import QApplication, QCalendarWidget
StyleSheet = '''
/*顶部导航区域*/
#qt_calendar_navigationbar {
background-color: rgb(0, 188, 212);
min-height: 100px;
}
/*上一个月按钮和下一个月按钮(从源码里找到的objectName)*/
#qt_calendar_prevmonth, #qt_calendar_nextmonth {
border: none; /*去掉边框*/
margin-top: 64px;
color: white;
min-width: 36px;
max-width: 36px;
min-height: 36px;
max-height: 36px;
border-radius: 18px; /*看来近似椭圆*/
font-weight: bold; /*字体加粗*/
qproperty-icon: none; /*去掉默认的方向键图片当然也可以自定义*/
background-color: transparent;/*背景颜色透明*/
}
#qt_calendar_prevmonth {
qproperty-text: "<"; /*修改按钮的文字*/
}
#qt_calendar_nextmonth {
qproperty-text: ">";
}
#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed {
background-color: rgba(235, 235, 235, 100);
}
/*,月控件*/
#qt_calendar_yearbutton, #qt_calendar_monthbutton {
color: white;
margin: 18px;
min-width: 60px;
border-radius: 30px;
}
#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed {
background-color: rgba(235, 235, 235, 100);
}
/*年份输入框*/
#qt_calendar_yearedit {
min-width: 50px;
color: white;
background: transparent;/*让输入框背景透明*/
}
#qt_calendar_yearedit::up-button { /*往上的按钮*/
width: 20px;
subcontrol-position: right;/*移动到右边*/
}
#qt_calendar_yearedit::down-button { /*往下的按钮*/
width: 20px;
subcontrol-position: left; /*移动到左边去*/
}
/*月份选择菜单*/
CalendarWidget QToolButton QMenu {
background-color: white;
}
CalendarWidget QToolButton QMenu::item {
padding: 10px;
}
CalendarWidget QToolButton QMenu::item:selected:enabled {
background-color: rgb(230, 230, 230);
}
CalendarWidget QToolButton::menu-indicator {
/*image: none;去掉月份选择下面的小箭头*/
subcontrol-position: right center;/*右边居中*/
}
/*下方的日历表格*/
#qt_calendar_calendarview {
outline: 0px;/*去掉选中后的虚线框*/
selection-background-color: rgb(0, 188, 212); /*选中背景颜色*/
}
'''
class CalendarWidget(QCalendarWidget):
def __init__(self, *args, **kwargs):
super(CalendarWidget, self).__init__(*args, **kwargs)
# 隐藏左边的序号
self.setVerticalHeaderFormat(self.NoVerticalHeader)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
w = CalendarWidget()
w.show()
sys.exit(app.exec_())
'''
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: CalendarWidget
@description: 日历
'''
import sys
from PyQt5.QtWidgets import QApplication, QCalendarWidget
StyleSheet = '''
/*顶部导航区域*/
#qt_calendar_navigationbar {
background-color: rgb(0, 188, 212);
min-height: 100px;
}
/*上一个月按钮和下一个月按钮(从源码里找到的objectName)*/
#qt_calendar_prevmonth, #qt_calendar_nextmonth {
border: none; /*去掉边框*/
margin-top: 64px;
color: white;
min-width: 36px;
max-width: 36px;
min-height: 36px;
max-height: 36px;
border-radius: 18px; /*看来近似椭圆*/
font-weight: bold; /*字体加粗*/
qproperty-icon: none; /*去掉默认的方向键图片当然也可以自定义*/
background-color: transparent;/*背景颜色透明*/
}
#qt_calendar_prevmonth {
qproperty-text: "<"; /*修改按钮的文字*/
}
#qt_calendar_nextmonth {
qproperty-text: ">";
}
#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed {
background-color: rgba(235, 235, 235, 100);
}
/*,月控件*/
#qt_calendar_yearbutton, #qt_calendar_monthbutton {
color: white;
margin: 18px;
min-width: 60px;
border-radius: 30px;
}
#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed {
background-color: rgba(235, 235, 235, 100);
}
/*年份输入框*/
#qt_calendar_yearedit {
min-width: 50px;
color: white;
background: transparent;/*让输入框背景透明*/
}
#qt_calendar_yearedit::up-button { /*往上的按钮*/
width: 20px;
subcontrol-position: right;/*移动到右边*/
}
#qt_calendar_yearedit::down-button { /*往下的按钮*/
width: 20px;
subcontrol-position: left; /*移动到左边去*/
}
/*月份选择菜单*/
CalendarWidget QToolButton QMenu {
background-color: white;
}
CalendarWidget QToolButton QMenu::item {
padding: 10px;
}
CalendarWidget QToolButton QMenu::item:selected:enabled {
background-color: rgb(230, 230, 230);
}
CalendarWidget QToolButton::menu-indicator {
/*image: none;去掉月份选择下面的小箭头*/
subcontrol-position: right center;/*右边居中*/
}
/*下方的日历表格*/
#qt_calendar_calendarview {
outline: 0px;/*去掉选中后的虚线框*/
selection-background-color: rgb(0, 188, 212); /*选中背景颜色*/
}
'''
class CalendarWidget(QCalendarWidget):
def __init__(self, *args, **kwargs):
super(CalendarWidget, self).__init__(*args, **kwargs)
# 隐藏左边的序号
self.setVerticalHeaderFormat(self.NoVerticalHeader)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
w = CalendarWidget()
w.show()
sys.exit(app.exec_())

View file

@ -1,10 +1,10 @@
# QCalendarWidget 日历控件 QSS 美化样式
主要改变顶部背景颜色和高度,上下月按钮、月份选择、年选择、菜单
详细美化都在代码里的QSS中注释了
效果图:
### [CalendarWidget.py](CalendarWidget.py)
# QCalendarWidget 日历控件 QSS 美化样式
主要改变顶部背景颜色和高度,上下月按钮、月份选择、年选择、菜单
详细美化都在代码里的QSS中注释了
效果图:
### [CalendarWidget.py](CalendarWidget.py)
![CalendarWidget](ScreenShot/CalendarWidget.gif)

View file

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View file

@ -1,82 +1,82 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月26日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: FileSystemModel
@description:
'''
import sys
from PyQt5.QtCore import QFileInfo
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFileSystemModel, QFileIconProvider, QApplication,\
QTreeView
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
# 图标提供类
class FileIconProvider(QFileIconProvider):
def __init__(self, *args, **kwargs):
super(FileIconProvider, self).__init__(*args, **kwargs)
self.DirIcon = QIcon("icons/folder.png")
self.TxtIcon = QIcon("icons/file.png")
def icon(self, type_info):
'''
:param fileInfo: 参考http://doc.qt.io/qt-5/qfileinfo.html
'''
if isinstance(type_info, QFileInfo):
# 如果type_info是QFileInfo类型则用getInfoIcon来返回图标
return self.getInfoIcon(type_info)
# 如果type_info是QFileIconProvider自身的IconType枚举类型则执行下面的方法
# 这里只能自定义通用的几种类型参考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum
'''
QFileIconProvider::Computer 0
QFileIconProvider::Desktop 1
QFileIconProvider::Trashcan 2
QFileIconProvider::Network 3
QFileIconProvider::Drive 4
QFileIconProvider::Folder 5
QFileIconProvider::File 6
'''
if type_info == QFileIconProvider.Folder:
# 如果是文件夹
return self.DirIcon
return super(FileIconProvider, self).icon(type_info)
def getInfoIcon(self, type_info):
if type_info.isDir(): # 文件夹
return self.DirIcon
if type_info.isFile() and type_info.suffix() == "txt": # 文件并且是txt
return self.TxtIcon
return super(FileIconProvider, self).icon(type_info)
if __name__ == "__main__":
app = QApplication(sys.argv)
model = QFileSystemModel()
model.setIconProvider(FileIconProvider()) # 设置为自定义的图标提供类
model.setRootPath("")
tree = QTreeView()
tree.setModel(model)
tree.setAnimated(False)
tree.setIndentation(20)
tree.setSortingEnabled(True)
tree.setWindowTitle("Dir View")
tree.resize(640, 480)
tree.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月26日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: FileSystemModel
@description:
'''
import sys
from PyQt5.QtCore import QFileInfo
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFileSystemModel, QFileIconProvider, QApplication,\
QTreeView
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
# 图标提供类
class FileIconProvider(QFileIconProvider):
def __init__(self, *args, **kwargs):
super(FileIconProvider, self).__init__(*args, **kwargs)
self.DirIcon = QIcon("icons/folder.png")
self.TxtIcon = QIcon("icons/file.png")
def icon(self, type_info):
'''
:param fileInfo: 参考http://doc.qt.io/qt-5/qfileinfo.html
'''
if isinstance(type_info, QFileInfo):
# 如果type_info是QFileInfo类型则用getInfoIcon来返回图标
return self.getInfoIcon(type_info)
# 如果type_info是QFileIconProvider自身的IconType枚举类型则执行下面的方法
# 这里只能自定义通用的几种类型参考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum
'''
QFileIconProvider::Computer 0
QFileIconProvider::Desktop 1
QFileIconProvider::Trashcan 2
QFileIconProvider::Network 3
QFileIconProvider::Drive 4
QFileIconProvider::Folder 5
QFileIconProvider::File 6
'''
if type_info == QFileIconProvider.Folder:
# 如果是文件夹
return self.DirIcon
return super(FileIconProvider, self).icon(type_info)
def getInfoIcon(self, type_info):
if type_info.isDir(): # 文件夹
return self.DirIcon
if type_info.isFile() and type_info.suffix() == "txt": # 文件并且是txt
return self.TxtIcon
return super(FileIconProvider, self).icon(type_info)
if __name__ == "__main__":
app = QApplication(sys.argv)
model = QFileSystemModel()
model.setIconProvider(FileIconProvider()) # 设置为自定义的图标提供类
model.setRootPath("")
tree = QTreeView()
tree.setModel(model)
tree.setAnimated(False)
tree.setIndentation(20)
tree.setSortingEnabled(True)
tree.setWindowTitle("Dir View")
tree.resize(640, 480)
tree.show()
sys.exit(app.exec_())

View file

@ -1,11 +1,11 @@
# QFileSystemModel 自定义图标
使用QFileSystemModel.setIconProvider(QFileIconProvider)来设置图标提供类
通过重写QFileIconProvider的icon方法来决定返回什么样的图标
见需求 [Issues#2](https://github.com/892768447/PyQt/issues/2)
截图
# QFileSystemModel 自定义图标
使用QFileSystemModel.setIconProvider(QFileIconProvider)来设置图标提供类
通过重写QFileIconProvider的icon方法来决定返回什么样的图标
见需求 [Issues#2](https://github.com/892768447/PyQt/issues/2)
截图
![1](ScreenShot/1.png)

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 385 B

After

Width:  |  Height:  |  Size: 385 B

View file

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 249 B

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View file

@ -1,75 +1,75 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月20日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: CircleLabel
@description:
'''
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter, QPainterPath
from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class Label(QLabel):
def __init__(self, *args, antialiasing=True, **kwargs):
super(Label, self).__init__(*args, **kwargs)
self.Antialiasing = antialiasing
self.setMaximumSize(200, 200)
self.setMinimumSize(200, 200)
self.radius = 100
#####################核心实现#########################
self.target = QPixmap(self.size()) # 大小和控件一样
self.target.fill(Qt.transparent) # 填充背景为透明
p = QPixmap("head.jpg").scaled( # 加载图片并缩放和控件一样大
200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
painter = QPainter(self.target)
if self.Antialiasing:
# 抗锯齿
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
# painter.setPen(# 测试圆圈
# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
path = QPainterPath()
path.addRoundedRect(
0, 0, self.width(), self.height(), self.radius, self.radius)
#**** 切割为圆形 ****#
painter.setClipPath(path)
# painter.drawPath(path) # 测试圆圈
painter.drawPixmap(0, 0, p)
self.setPixmap(self.target)
#####################核心实现#########################
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QHBoxLayout(self)
layout.addWidget(Label(self))
layout.addWidget(Label(self, antialiasing=False))
self.setStyleSheet("background: black;")
if __name__ == "__main__":
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月20日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: CircleLabel
@description:
'''
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter, QPainterPath
from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class Label(QLabel):
def __init__(self, *args, antialiasing=True, **kwargs):
super(Label, self).__init__(*args, **kwargs)
self.Antialiasing = antialiasing
self.setMaximumSize(200, 200)
self.setMinimumSize(200, 200)
self.radius = 100
#####################核心实现#########################
self.target = QPixmap(self.size()) # 大小和控件一样
self.target.fill(Qt.transparent) # 填充背景为透明
p = QPixmap("Images/head.jpg").scaled( # 加载图片并缩放和控件一样大
200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
painter = QPainter(self.target)
if self.Antialiasing:
# 抗锯齿
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
# painter.setPen(# 测试圆圈
# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
path = QPainterPath()
path.addRoundedRect(
0, 0, self.width(), self.height(), self.radius, self.radius)
#**** 切割为圆形 ****#
painter.setClipPath(path)
# painter.drawPath(path) # 测试圆圈
painter.drawPixmap(0, 0, p)
self.setPixmap(self.target)
#####################核心实现#########################
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QHBoxLayout(self)
layout.addWidget(Label(self))
layout.addWidget(Label(self, antialiasing=False))
self.setStyleSheet("background: black;")
if __name__ == "__main__":
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1,11 +1,11 @@
# 消息提示框的按钮和图标美化
### [1.方案一](方案一/)
- 1.1 该方案使用dialogbuttonbox-buttons-have-icons: 1; 开启自带的图标样式
- 1.2 再利用dialog-xx-icon: url(); 来设置自定义的图标, 具体参考[list-of-icons](http://doc.qt.io/qt-5/stylesheet-reference.html#list-of-icons)
- 1.3 缺点 部分按钮图标无效,无法自定义不同按钮的颜色
### [2.方案二](方案二/)
- 2.1 采用样式表中的属性选择器 QPushButton[text="xxx"] 可以根据按钮中的文字来区分
- 2.2 在利用属性样式qproperty-icon: url();来设置自定义图标
# 消息提示框的按钮和图标美化
### [1.方案一](方案一/)
- 1.1 该方案使用dialogbuttonbox-buttons-have-icons: 1; 开启自带的图标样式
- 1.2 再利用dialog-xx-icon: url(); 来设置自定义的图标, 具体参考[list-of-icons](http://doc.qt.io/qt-5/stylesheet-reference.html#list-of-icons)
- 1.3 缺点 部分按钮图标无效,无法自定义不同按钮的颜色
### [2.方案二](方案二/)
- 2.1 采用样式表中的属性选择器 QPushButton[text="xxx"] 可以根据按钮中的文字来区分
- 2.2 在利用属性样式qproperty-icon: url();来设置自定义图标
- 2.3 解决方案一的缺点

View file

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View file

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View file

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View file

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View file

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 7 KiB

View file

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View file

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View file

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

Before

Width:  |  Height:  |  Size: 9 KiB

After

Width:  |  Height:  |  Size: 9 KiB

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View file

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View file

@ -1,7 +1,7 @@
# 方案一
截图
![critical](ScreenShot/critical.png)
![information](ScreenShot/information.png)
![question](ScreenShot/question.png)
# 方案一
截图
![critical](ScreenShot/critical.png)
![information](ScreenShot/information.png)
![question](ScreenShot/question.png)
![warning](ScreenShot/warning.png)

View file

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View file

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -1,40 +1,40 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: critical
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-ok-icon: url(../icons/Ok.png);
dialog-open-icon: url(../icons/Open.png);
dialog-save-icon: url(../icons/Save.png);
dialog-cancel-icon: url(../icons/Cancel.png);
}
QMessageBox {
messagebox-critical-icon: url(../icons/Close.png);
}
''')
QMessageBox.critical(None, "提示critical", "消息",
QMessageBox.Ok |
QMessageBox.Open |
QMessageBox.Save |
QMessageBox.Cancel)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: critical
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-ok-icon: url(../icons/Ok.png);
dialog-open-icon: url(../icons/Open.png);
dialog-save-icon: url(../icons/Save.png);
dialog-cancel-icon: url(../icons/Cancel.png);
}
QMessageBox {
messagebox-critical-icon: url(../icons/Close.png);
}
''')
QMessageBox.critical(None, "提示critical", "消息",
QMessageBox.Ok |
QMessageBox.Open |
QMessageBox.Save |
QMessageBox.Cancel)
sys.exit()

View file

@ -1,40 +1,40 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: information
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-close-icon: url(../icons/Close.png);
dialog-discard-icon: url(../icons/Discard.png);
dialog-apply-icon: url(../icons/Apply.png);
dialog-reset-icon: url(../icons/Reset.png);
}
QMessageBox {
messagebox-information-icon: url(../icons/Ok.png);
}
''')
QMessageBox.information(None, "提示information", "消息",
QMessageBox.Close |
QMessageBox.Discard |
QMessageBox.Apply |
QMessageBox.Reset)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: information
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-close-icon: url(../icons/Close.png);
dialog-discard-icon: url(../icons/Discard.png);
dialog-apply-icon: url(../icons/Apply.png);
dialog-reset-icon: url(../icons/Reset.png);
}
QMessageBox {
messagebox-information-icon: url(../icons/Ok.png);
}
''')
QMessageBox.information(None, "提示information", "消息",
QMessageBox.Close |
QMessageBox.Discard |
QMessageBox.Apply |
QMessageBox.Reset)
sys.exit()

View file

@ -1,39 +1,39 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: question
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-help-icon: url(../icons/Help.png);
dialog-yes-icon: url(../icons/Yes.png);
}
QMessageBox {
messagebox-question-icon: url(../icons/Ok.png);
}
''')
QMessageBox.question(None, "提示question", "消息",
QMessageBox.RestoreDefaults |
QMessageBox.Help |
QMessageBox.SaveAll |
QMessageBox.Yes |
QMessageBox.YesToAll)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: question
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-help-icon: url(../icons/Help.png);
dialog-yes-icon: url(../icons/Yes.png);
}
QMessageBox {
messagebox-question-icon: url(../icons/Ok.png);
}
''')
QMessageBox.question(None, "提示question", "消息",
QMessageBox.RestoreDefaults |
QMessageBox.Help |
QMessageBox.SaveAll |
QMessageBox.Yes |
QMessageBox.YesToAll)
sys.exit()

View file

@ -1,39 +1,39 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: warning
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-no-icon: url(../icons/No.png);
dialog-abort-icon: url(../icons/Abort.png);
dialog-retry-icon: url(../icons/Retry.png);
dialog-ignore-icon: url(../icons/Ignore.png);
}
QMessageBox {
messagebox-warning-icon: url(../icons/Ok.png);
}
''')
QMessageBox.warning(None, "提示warning", "消息",
QMessageBox.No |
QMessageBox.NoToAll |
QMessageBox.Abort |
QMessageBox.Retry |
QMessageBox.Ignore)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: warning
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''QDialogButtonBox {
dialogbuttonbox-buttons-have-icons: 1;
dialog-no-icon: url(../icons/No.png);
dialog-abort-icon: url(../icons/Abort.png);
dialog-retry-icon: url(../icons/Retry.png);
dialog-ignore-icon: url(../icons/Ignore.png);
}
QMessageBox {
messagebox-warning-icon: url(../icons/Ok.png);
}
''')
QMessageBox.warning(None, "提示warning", "消息",
QMessageBox.No |
QMessageBox.NoToAll |
QMessageBox.Abort |
QMessageBox.Retry |
QMessageBox.Ignore)
sys.exit()

View file

@ -1,7 +1,7 @@
# 方案二
截图
![critical](ScreenShot/critical.png)
![information](ScreenShot/information.png)
![question](ScreenShot/question.png)
# 方案二
截图
![critical](ScreenShot/critical.png)
![information](ScreenShot/information.png)
![question](ScreenShot/question.png)
![warning](ScreenShot/warning.png)

View file

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View file

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -1,71 +1,71 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: critical
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="OK"] {
background: red;
qproperty-icon: url(../icons/Ok.png);
}
QPushButton[text="OK"]:hover {
background: darkRed;
}
QPushButton[text="Open"] {
background: green;
qproperty-icon: url(../icons/Open.png);
}
QPushButton[text="Open"]:hover {
background: darkGreen;
}
QPushButton[text="Save"] {
background: blue;
qproperty-icon: url(../icons/Save.png);
}
QPushButton[text="Save"]:hover {
background: darkBlue;
}
QPushButton[text="Cancel"] {
background: cyan;
qproperty-icon: url(../icons/Cancel.png);
}
QPushButton[text="Cancel"]:hover {
background: darkCyan;
}
QMessageBox {
messagebox-critical-icon: url(../icons/Close.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
''')
QMessageBox.critical(None, "提示critical", "消息",
QMessageBox.Ok |
QMessageBox.Open |
QMessageBox.Save |
QMessageBox.Cancel)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: critical
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="OK"] {
background: red;
qproperty-icon: url(../icons/Ok.png);
}
QPushButton[text="OK"]:hover {
background: darkRed;
}
QPushButton[text="Open"] {
background: green;
qproperty-icon: url(../icons/Open.png);
}
QPushButton[text="Open"]:hover {
background: darkGreen;
}
QPushButton[text="Save"] {
background: blue;
qproperty-icon: url(../icons/Save.png);
}
QPushButton[text="Save"]:hover {
background: darkBlue;
}
QPushButton[text="Cancel"] {
background: cyan;
qproperty-icon: url(../icons/Cancel.png);
}
QPushButton[text="Cancel"]:hover {
background: darkCyan;
}
QMessageBox {
messagebox-critical-icon: url(../icons/Close.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
''')
QMessageBox.critical(None, "提示critical", "消息",
QMessageBox.Ok |
QMessageBox.Open |
QMessageBox.Save |
QMessageBox.Cancel)
sys.exit()

View file

@ -1,71 +1,71 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: information
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="Close"] {
background: red;
qproperty-icon: url(../icons/Close.png);
}
QPushButton[text="Close"]:hover {
background: darkRed;
}
QPushButton[text="Discard"] {
background: green;
qproperty-icon: url(../icons/Discard.png);
}
QPushButton[text="Discard"]:hover {
background: darkGreen;
}
QPushButton[text="Apply"] {
background: blue;
qproperty-icon: url(../icons/Apply.png);
}
QPushButton[text="Apply"]:hover {
background: darkBlue;
}
QPushButton[text="Reset"] {
background: cyan;
qproperty-icon: url(../icons/Reset.png);
}
QPushButton[text="Reset"]:hover {
background: darkCyan;
}
QMessageBox {
messagebox-information-icon: url(../icons/Close.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
''')
QMessageBox.information(None, "提示information", "消息",
QMessageBox.Close |
QMessageBox.Discard |
QMessageBox.Apply |
QMessageBox.Reset)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: information
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="Close"] {
background: red;
qproperty-icon: url(../icons/Close.png);
}
QPushButton[text="Close"]:hover {
background: darkRed;
}
QPushButton[text="Discard"] {
background: green;
qproperty-icon: url(../icons/Discard.png);
}
QPushButton[text="Discard"]:hover {
background: darkGreen;
}
QPushButton[text="Apply"] {
background: blue;
qproperty-icon: url(../icons/Apply.png);
}
QPushButton[text="Apply"]:hover {
background: darkBlue;
}
QPushButton[text="Reset"] {
background: cyan;
qproperty-icon: url(../icons/Reset.png);
}
QPushButton[text="Reset"]:hover {
background: darkCyan;
}
QMessageBox {
messagebox-information-icon: url(../icons/Close.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
''')
QMessageBox.information(None, "提示information", "消息",
QMessageBox.Close |
QMessageBox.Discard |
QMessageBox.Apply |
QMessageBox.Reset)
sys.exit()

View file

@ -1,80 +1,80 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: question
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="Restore Defaults"] {
background: red;
qproperty-icon: url(../icons/RestoreDefaults.png);
}
QPushButton[text="Restore Defaults"]:hover {
background: darkRed;
}
QPushButton[text="Help"] {
background: green;
qproperty-icon: url(../icons/Help.png);
}
QPushButton[text="Help"]:hover {
background: darkGreen;
}
QPushButton[text="Save All"] {
background: blue;
qproperty-icon: url(../icons/SaveAll.png);
}
QPushButton[text="Save All"]:hover {
background: darkBlue;
}
QPushButton[text="&Yes"] {
background: cyan;
qproperty-icon: url(../icons/Yes.png);
}
QPushButton[text="&Yes"]:hover {
background: darkCyan;
}
QPushButton[text="Yes to &All"] {
background: magenta;
qproperty-icon: url(../icons/YesToAll.png);
}
QPushButton[text="Yes to &All"]:hover {
background: darkMegenta;
}
QMessageBox {
messagebox-question-icon: url(../icons/Close.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
''')
QMessageBox.question(None, "提示question", "消息",
QMessageBox.RestoreDefaults |
QMessageBox.Help |
QMessageBox.SaveAll |
QMessageBox.Yes |
QMessageBox.YesToAll)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: question
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="Restore Defaults"] {
background: red;
qproperty-icon: url(../icons/RestoreDefaults.png);
}
QPushButton[text="Restore Defaults"]:hover {
background: darkRed;
}
QPushButton[text="Help"] {
background: green;
qproperty-icon: url(../icons/Help.png);
}
QPushButton[text="Help"]:hover {
background: darkGreen;
}
QPushButton[text="Save All"] {
background: blue;
qproperty-icon: url(../icons/SaveAll.png);
}
QPushButton[text="Save All"]:hover {
background: darkBlue;
}
QPushButton[text="&Yes"] {
background: cyan;
qproperty-icon: url(../icons/Yes.png);
}
QPushButton[text="&Yes"]:hover {
background: darkCyan;
}
QPushButton[text="Yes to &All"] {
background: magenta;
qproperty-icon: url(../icons/YesToAll.png);
}
QPushButton[text="Yes to &All"]:hover {
background: darkMegenta;
}
QMessageBox {
messagebox-question-icon: url(../icons/Close.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
''')
QMessageBox.question(None, "提示question", "消息",
QMessageBox.RestoreDefaults |
QMessageBox.Help |
QMessageBox.SaveAll |
QMessageBox.Yes |
QMessageBox.YesToAll)
sys.exit()

View file

@ -1,84 +1,84 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: warning
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="&No"] {
background: red;
qproperty-icon: url(../icons/No.png);
}
QPushButton[text="&No"]:hover {
background: darkRed;
}
QPushButton[text="N&o to All"] {
background: green;
qproperty-icon: url(../icons/NoToAll.png);
}
QPushButton[text="N&o to All"]:hover {
background: darkGreen;
}
QPushButton[text="Abort"] {
background: blue;
qproperty-icon: url(../icons/Abort.png);
}
QPushButton[text="Abort"]:hover {
background: darkBlue;
}
QPushButton[text="Retry"] {
background: cyan;
qproperty-icon: url(../icons/Retry.png);
}
QPushButton[text="Retry"]:hover {
background: darkCyan;
}
QPushButton[text="Ignore"] {
background: magenta;
qproperty-icon: url(../icons/Ignore.png);
}
QPushButton[text="Ignore"]:hover {
background: darkMegenta;
}
QMessageBox {
messagebox-warning-icon: url(../icons/No.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
QMessageBox QLabel {
color: red;
}
''')
QMessageBox.warning(None, "提示warning", "消息",
QMessageBox.No |
QMessageBox.NoToAll |
QMessageBox.Abort |
QMessageBox.Retry |
QMessageBox.Ignore)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月17日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: warning
@description:
'''
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
app = QApplication(sys.argv)
app.setStyleSheet('''
QPushButton[text="&No"] {
background: red;
qproperty-icon: url(../icons/No.png);
}
QPushButton[text="&No"]:hover {
background: darkRed;
}
QPushButton[text="N&o to All"] {
background: green;
qproperty-icon: url(../icons/NoToAll.png);
}
QPushButton[text="N&o to All"]:hover {
background: darkGreen;
}
QPushButton[text="Abort"] {
background: blue;
qproperty-icon: url(../icons/Abort.png);
}
QPushButton[text="Abort"]:hover {
background: darkBlue;
}
QPushButton[text="Retry"] {
background: cyan;
qproperty-icon: url(../icons/Retry.png);
}
QPushButton[text="Retry"]:hover {
background: darkCyan;
}
QPushButton[text="Ignore"] {
background: magenta;
qproperty-icon: url(../icons/Ignore.png);
}
QPushButton[text="Ignore"]:hover {
background: darkMegenta;
}
QMessageBox {
messagebox-warning-icon: url(../icons/No.png);
}
QMessageBox QPushButton {
min-width: 95px;
min-height: 30px;
border-radius: 5px;
}
QMessageBox QLabel {
color: red;
}
''')
QMessageBox.warning(None, "提示warning", "消息",
QMessageBox.No |
QMessageBox.NoToAll |
QMessageBox.Abort |
QMessageBox.Retry |
QMessageBox.Ignore)
sys.exit()

View file

@ -1,105 +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_())
#!/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_())

View file

@ -1,10 +1,10 @@
# QProgressBar进度条 QSS 美化样式
主要改变背景颜色、高度、边框、块颜色、边框、圆角
详细美化都在代码里的QSS中注释了
效果图:
### [ProgressBar.py](ProgressBar.py)
# QProgressBar进度条 QSS 美化样式
主要改变背景颜色、高度、边框、块颜色、边框、圆角
详细美化都在代码里的QSS中注释了
效果图:
### [ProgressBar.py](ProgressBar.py)
![ProgressBar](ScreenShot/ProgressBar.gif)

View file

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -1,113 +1,113 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月29日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: ButtonHover
@description:
'''
import sys
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
StyleSheet = '''
/*这里是通用设置所有按钮都有效不过后面的可以覆盖这个*/
QPushButton {
border: none; /*去掉边框*/
}
/*
QPushButton#xxx
或者
#xx
都表示通过设置的objectName来指定
*/
QPushButton#RedButton {
background-color: #f44336; /*背景颜色*/
}
#RedButton:hover {
background-color: #e57373; /*鼠标悬停时背景颜色*/
}
/*注意pressed一定要放在hover的后面否则没有效果*/
#RedButton:pressed {
background-color: #ffcdd2; /*鼠标按下不放时背景颜色*/
}
#GreenButton {
background-color: #4caf50;
border-radius: 5px; /*圆角*/
}
#GreenButton:hover {
background-color: #81c784;
}
#GreenButton:pressed {
background-color: #c8e6c9;
}
#BlueButton {
background-color: #2196f3;
/*限制最小最大尺寸*/
min-width: 96px;
max-width: 96px;
min-height: 96px;
max-height: 96px;
border-radius: 48px; /*圆形*/
}
#BlueButton:hover {
background-color: #64b5f6;
}
#BlueButton:pressed {
background-color: #bbdefb;
}
#OrangeButton {
max-height: 48px;
border-top-right-radius: 20px; /*右上角圆角*/
border-bottom-left-radius: 20px; /*左下角圆角*/
background-color: #ff9800;
}
#OrangeButton:hover {
background-color: #ffb74d;
}
#OrangeButton:pressed {
background-color: #ffe0b2;
}
/*根据文字内容来区分按钮,同理还可以根据其它属性来区分*/
QPushButton[text="purple button"] {
color: white; /*文字颜色*/
background-color: #9c27b0;
}
'''
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QHBoxLayout(self)
layout.addWidget(QPushButton("red button", self,
objectName="RedButton", minimumHeight=48))
layout.addWidget(QPushButton("green button", self,
objectName="GreenButton", minimumHeight=48))
layout.addWidget(QPushButton("blue button", self,
objectName="BlueButton", minimumHeight=48))
layout.addWidget(QPushButton("orange button", self,
objectName="OrangeButton", minimumHeight=48))
layout.addWidget(QPushButton("purple button", self,
objectName="PurpleButton", minimumHeight=48))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
w = Window()
w.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月29日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: ButtonHover
@description:
'''
import sys
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
StyleSheet = '''
/*这里是通用设置所有按钮都有效不过后面的可以覆盖这个*/
QPushButton {
border: none; /*去掉边框*/
}
/*
QPushButton#xxx
或者
#xx
都表示通过设置的objectName来指定
*/
QPushButton#RedButton {
background-color: #f44336; /*背景颜色*/
}
#RedButton:hover {
background-color: #e57373; /*鼠标悬停时背景颜色*/
}
/*注意pressed一定要放在hover的后面否则没有效果*/
#RedButton:pressed {
background-color: #ffcdd2; /*鼠标按下不放时背景颜色*/
}
#GreenButton {
background-color: #4caf50;
border-radius: 5px; /*圆角*/
}
#GreenButton:hover {
background-color: #81c784;
}
#GreenButton:pressed {
background-color: #c8e6c9;
}
#BlueButton {
background-color: #2196f3;
/*限制最小最大尺寸*/
min-width: 96px;
max-width: 96px;
min-height: 96px;
max-height: 96px;
border-radius: 48px; /*圆形*/
}
#BlueButton:hover {
background-color: #64b5f6;
}
#BlueButton:pressed {
background-color: #bbdefb;
}
#OrangeButton {
max-height: 48px;
border-top-right-radius: 20px; /*右上角圆角*/
border-bottom-left-radius: 20px; /*左下角圆角*/
background-color: #ff9800;
}
#OrangeButton:hover {
background-color: #ffb74d;
}
#OrangeButton:pressed {
background-color: #ffe0b2;
}
/*根据文字内容来区分按钮,同理还可以根据其它属性来区分*/
QPushButton[text="purple button"] {
color: white; /*文字颜色*/
background-color: #9c27b0;
}
'''
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QHBoxLayout(self)
layout.addWidget(QPushButton("red button", self,
objectName="RedButton", minimumHeight=48))
layout.addWidget(QPushButton("green button", self,
objectName="GreenButton", minimumHeight=48))
layout.addWidget(QPushButton("blue button", self,
objectName="BlueButton", minimumHeight=48))
layout.addWidget(QPushButton("orange button", self,
objectName="OrangeButton", minimumHeight=48))
layout.addWidget(QPushButton("purple button", self,
objectName="PurpleButton", minimumHeight=48))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
w = Window()
w.show()
sys.exit(app.exec_())

View file

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -1,90 +1,90 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年2月1日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: PushButtonFont
@description:
'''
import sys
from PyQt5.QtCore import QPropertyAnimation, Qt, QRectF
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtWidgets import QPushButton, QApplication, QStyleOptionButton,\
QStylePainter, QStyle
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class PushButtonFont(QPushButton):
LoadingText = "\uf110"
def __init__(self, *args, **kwargs):
super(PushButtonFont, self).__init__(*args, **kwargs)
self.fontSize = self.font().pointSize() * 2
self._rotateAnimationStarted = False
self._rotateAnimation = QPropertyAnimation(self)
self._rotateAnimation.setTargetObject(self)
self._rotateAnimation.setStartValue(1)
self._rotateAnimation.setEndValue(12)
self._rotateAnimation.setDuration(1000)
self._rotateAnimation.setLoopCount(-1) # 无限循环
self._rotateAnimation.valueChanged.connect(self.update)
self.clicked.connect(self._onClick)
def paintEvent(self, _):
option = QStyleOptionButton()
self.initStyleOption(option)
painter = QStylePainter(self)
if self._rotateAnimationStarted:
option.text = ""
painter.drawControl(QStyle.CE_PushButton, option)
if not self._rotateAnimationStarted:
return
painter.save()
font = self.font()
font.setPointSize(self.fontSize)
font.setFamily("FontAwesome")
painter.setFont(font)
# 变换坐标为正中间
painter.translate(self.rect().center())
# 旋转90度
painter.rotate(self._rotateAnimation.currentValue() * 30)
fm = self.fontMetrics()
# 在变换坐标后的正中间画文字
w = fm.width(self.LoadingText)
h = fm.height()
painter.drawText(
QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter,
self.LoadingText)
painter.restore()
def _onClick(self):
if self._rotateAnimationStarted:
self._rotateAnimationStarted = False
self._rotateAnimation.stop()
return
self._rotateAnimationStarted = True
self._rotateAnimation.start()
def update(self, _=None):
super(PushButtonFont, self).update()
if __name__ == "__main__":
app = QApplication(sys.argv)
# 加载字体到字体库中
QFontDatabase.addApplicationFont(
"Fonts/FontAwesome/fontawesome-webfont.ttf")
w = PushButtonFont("点击加载")
w.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年2月1日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: PushButtonFont
@description:
'''
import sys
from PyQt5.QtCore import QPropertyAnimation, Qt, QRectF
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtWidgets import QPushButton, QApplication, QStyleOptionButton,\
QStylePainter, QStyle
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class PushButtonFont(QPushButton):
LoadingText = "\uf110"
def __init__(self, *args, **kwargs):
super(PushButtonFont, self).__init__(*args, **kwargs)
self.fontSize = self.font().pointSize() * 2
self._rotateAnimationStarted = False
self._rotateAnimation = QPropertyAnimation(self)
self._rotateAnimation.setTargetObject(self)
self._rotateAnimation.setStartValue(1)
self._rotateAnimation.setEndValue(12)
self._rotateAnimation.setDuration(1000)
self._rotateAnimation.setLoopCount(-1) # 无限循环
self._rotateAnimation.valueChanged.connect(self.update)
self.clicked.connect(self._onClick)
def paintEvent(self, _):
option = QStyleOptionButton()
self.initStyleOption(option)
painter = QStylePainter(self)
if self._rotateAnimationStarted:
option.text = ""
painter.drawControl(QStyle.CE_PushButton, option)
if not self._rotateAnimationStarted:
return
painter.save()
font = self.font()
font.setPointSize(self.fontSize)
font.setFamily("FontAwesome")
painter.setFont(font)
# 变换坐标为正中间
painter.translate(self.rect().center())
# 旋转90度
painter.rotate(self._rotateAnimation.currentValue() * 30)
fm = self.fontMetrics()
# 在变换坐标后的正中间画文字
w = fm.width(self.LoadingText)
h = fm.height()
painter.drawText(
QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter,
self.LoadingText)
painter.restore()
def _onClick(self):
if self._rotateAnimationStarted:
self._rotateAnimationStarted = False
self._rotateAnimation.stop()
return
self._rotateAnimationStarted = True
self._rotateAnimation.start()
def update(self, _=None):
super(PushButtonFont, self).update()
if __name__ == "__main__":
app = QApplication(sys.argv)
# 加载字体到字体库中
QFontDatabase.addApplicationFont(
"Fonts/FontAwesome/fontawesome-webfont.ttf")
w = PushButtonFont("点击加载")
w.show()
sys.exit(app.exec_())

View file

@ -1,116 +1,116 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年2月1日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: PushButtonLine
@description:
'''
from random import randint
import sys
from PyQt5.QtCore import QTimer, QThread, pyqtSignal
from PyQt5.QtGui import QPainter, QColor, QPen
from PyQt5.QtWidgets import QPushButton, QApplication, QWidget, QVBoxLayout
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
StyleSheet = '''
PushButtonLine {
color: white;
border: none;
min-height: 48px;
background-color: #90caf9;
}
'''
class LoadingThread(QThread):
valueChanged = pyqtSignal(float) # 当前值/最大值
def __init__(self, *args, **kwargs):
super(LoadingThread, self).__init__(*args, **kwargs)
self.totalValue = randint(100, 200) # 模拟最大
def run(self):
for i in range(self.totalValue + 1):
self.valueChanged.emit(i / self.totalValue)
QThread.msleep(randint(300, 600))
class PushButtonLine(QPushButton):
lineColor = QColor(0, 150, 136)
def __init__(self, *args, **kwargs):
self._waitText = kwargs.pop("waitText", "等待中")
super(PushButtonLine, self).__init__(*args, **kwargs)
self._text = self.text()
self._percent = 0
self._timer = QTimer(self, timeout=self.update)
self.clicked.connect(self.start)
def paintEvent(self, event):
super(PushButtonLine, self).paintEvent(event)
if not self._timer.isActive():
return
# 画进度
painter = QPainter(self)
pen = QPen(self.lineColor)
pen.setWidth(4)
painter.setPen(pen)
painter.drawLine(0, self.height(), self.width()
* self._percent, self.height())
def start(self):
if hasattr(self, "loadingThread"):
return self.stop()
self.loadingThread = LoadingThread(self)
self.loadingThread.valueChanged.connect(self.setPercent)
self._timer.start(200) # 200ms
self.loadingThread.start()
self.setText(self._waitText)
def stop(self):
self.loadingThread.valueChanged.disconnect(self.setPercent)
self.loadingThread.terminate()
self.loadingThread.deleteLater()
del self.loadingThread
self._percent = 0
self._timer.stop()
self.setText(self._text)
def setPercent(self, v):
self._percent = v
if v == 1:
self.stop()
self.update()
def setLineColor(self, color):
self.lineColor = QColor(color)
return self
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QVBoxLayout(self)
layout.addWidget(PushButtonLine("点击加载"))
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ef5350"))
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ffc107"))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
w = Window()
w.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年2月1日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: PushButtonLine
@description:
'''
from random import randint
import sys
from PyQt5.QtCore import QTimer, QThread, pyqtSignal
from PyQt5.QtGui import QPainter, QColor, QPen
from PyQt5.QtWidgets import QPushButton, QApplication, QWidget, QVBoxLayout
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
StyleSheet = '''
PushButtonLine {
color: white;
border: none;
min-height: 48px;
background-color: #90caf9;
}
'''
class LoadingThread(QThread):
valueChanged = pyqtSignal(float) # 当前值/最大值
def __init__(self, *args, **kwargs):
super(LoadingThread, self).__init__(*args, **kwargs)
self.totalValue = randint(100, 200) # 模拟最大
def run(self):
for i in range(self.totalValue + 1):
self.valueChanged.emit(i / self.totalValue)
QThread.msleep(randint(300, 600))
class PushButtonLine(QPushButton):
lineColor = QColor(0, 150, 136)
def __init__(self, *args, **kwargs):
self._waitText = kwargs.pop("waitText", "等待中")
super(PushButtonLine, self).__init__(*args, **kwargs)
self._text = self.text()
self._percent = 0
self._timer = QTimer(self, timeout=self.update)
self.clicked.connect(self.start)
def paintEvent(self, event):
super(PushButtonLine, self).paintEvent(event)
if not self._timer.isActive():
return
# 画进度
painter = QPainter(self)
pen = QPen(self.lineColor)
pen.setWidth(4)
painter.setPen(pen)
painter.drawLine(0, self.height(), self.width()
* self._percent, self.height())
def start(self):
if hasattr(self, "loadingThread"):
return self.stop()
self.loadingThread = LoadingThread(self)
self.loadingThread.valueChanged.connect(self.setPercent)
self._timer.start(200) # 200ms
self.loadingThread.start()
self.setText(self._waitText)
def stop(self):
self.loadingThread.valueChanged.disconnect(self.setPercent)
self.loadingThread.terminate()
self.loadingThread.deleteLater()
del self.loadingThread
self._percent = 0
self._timer.stop()
self.setText(self._text)
def setPercent(self, v):
self._percent = v
if v == 1:
self.stop()
self.update()
def setLineColor(self, color):
self.lineColor = QColor(color)
return self
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QVBoxLayout(self)
layout.addWidget(PushButtonLine("点击加载"))
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ef5350"))
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ffc107"))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1,20 +1,20 @@
# QScrollBar滚动条样式美化
### 滚动条分两个方向
- horizontal 横向
- vertical 纵向
### 简单说明
- 横向或纵向滚动条整体也就是horizontal、vertical
- 滚动条上面的小滑块handle
- 纵向上部、横向左侧区域sub-page
- 纵向下部、横向右侧区域add-page
- 纵向上部、横向左侧三角形区域sub-line
- 纵向下部、横向右侧三角形区域add-line
- 纵向上部、横向左侧三角形up-arrow、left-arrow
- 纵向下部、横向右侧三角形down-arrow、right-arrow
截图
![1](ScreenShot/1.jpg)
# QScrollBar滚动条样式美化
### 滚动条分两个方向
- horizontal 横向
- vertical 纵向
### 简单说明
- 横向或纵向滚动条整体也就是horizontal、vertical
- 滚动条上面的小滑块handle
- 纵向上部、横向左侧区域sub-page
- 纵向下部、横向右侧区域add-page
- 纵向上部、横向左侧三角形区域sub-line
- 纵向下部、横向右侧三角形区域add-line
- 纵向上部、横向左侧三角形up-arrow、left-arrow
- 纵向下部、横向右侧三角形down-arrow、right-arrow
截图
![1](ScreenShot/1.jpg)
![2](ScreenShot/2.jpg)

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -1,45 +1,45 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月20日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: ScrollBar
@description:
'''
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QTextEdit, QApplication
import chardet
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class Window(QTextEdit):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
# 设置横向纵向滚动条总是显示
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
with open("ScrollBar.qss", "rb") as fp:
content = fp.read()
encoding = chardet.detect(content) or {}
content = content.decode(encoding.get("encoding") or "utf-8")
self.setText(content)
# 设置样式
self.setStyleSheet(content)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
app.setApplicationName("滚动条样式")
app.setApplicationDisplayName("滚动条样式")
window = Window()
window.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年1月20日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: 892768447@qq.com
@file: ScrollBar
@description:
'''
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QTextEdit, QApplication
import chardet
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class Window(QTextEdit):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
# 设置横向纵向滚动条总是显示
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
with open("ScrollBar.qss", "rb") as fp:
content = fp.read()
encoding = chardet.detect(content) or {}
content = content.decode(encoding.get("encoding") or "utf-8")
self.setText(content)
# 设置样式
self.setStyleSheet(content)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
app.setApplicationName("滚动条样式")
app.setApplicationDisplayName("滚动条样式")
window = Window()
window.show()
sys.exit(app.exec_())

View file

@ -1,142 +1,142 @@
/*QScrollBar Style*/
/*纵向滚动条*/
QScrollBar:vertical {
background: transparent; /*背景透明*/
width: 10px; /*宽度*/
margin: 0px 0px 0px 0px; /**/
padding-top: 12px; /*距离上面12px*/
padding-bottom: 12px; /*距离底部12px*/
}
/*横向滚动条*/
QScrollBar:horizontal {
background: transparent;
height: 10px; /*高度*/
margin: 0px 0px 0px 0px;
padding-left: 12px; /*距离左边12px*/
padding-right: 12px; /*距离右边12px*/
}
/*当鼠标放到纵向或者横向滚动条上面时*/
QScrollBar:vertical:hover,QScrollBar:horizontal:hover {
background: rgba(0, 0, 0, 30); /*修改背景透明度 30*/
border-radius: 5px; /*圆角*/
}
/*纵向滚动条上面的滑块*/
QScrollBar::handle:vertical {
background: rgba(0, 0, 0, 50);
width: 10px;
border-radius: 5px;
border: none;
}
/*横向滚动条上面的滑块*/
QScrollBar::handle:horizontal {
background: rgba(0, 0, 0, 50);
height: 10px;
border-radius: 5px;
border: none;
}
/*当鼠标放到滚动条滑块上面时改变透明度实现颜色的深浅变化*/
QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover {
background: rgba(0, 0, 0, 100);
}
/*纵向滚动条下部分块*/
QScrollBar::add-page:vertical {
width: 10px;
background: transparent;
}
/*横向滚动条后面部分块*/
QScrollBar::add-page:horizontal {
height: 10px;
background: transparent;
}
/*纵向滚动条上面部分块*/
QScrollBar::sub-page:vertical {
width: 10px;
background: transparent;
}
/*横向滚动条左部分块*/
QScrollBar::sub-page:horizontal {
height: 10px;
background: transparent;
}
/*纵向滚动条顶部三角形位置*/
QScrollBar::sub-line:vertical {
height: 12px;
width: 10px;
background: transparent;
subcontrol-position: top;
}
/*横向滚动条左侧三角形位置*/
QScrollBar::sub-line:horizontal {
height: 10px;
width: 12px;
background: transparent;
subcontrol-position: left;
}
/*纵向滚动条向上的三角形小图标*/
QScrollBar::up-arrow:vertical {
image: url(scrollbar/scrollbar_arrowup_normal.png);
}
/*横向滚动条左边的三角形小图标*/
QScrollBar::left-arrow:horizontal {
image: url(scrollbar/scrollbar_arrowleft_normal.png);
}
/*纵向滚动条向上的三角形小图标 鼠标悬停*/
QScrollBar::up-arrow:vertical:hover {
image: url(scrollbar/scrollbar_arrowup_down.png);
}
/*横向滚动条左边的三角形小图标 鼠标悬停*/
QScrollBar::left-arrow:horizontal:hover {
image: url(scrollbar/scrollbar_arrowleft_down.png);
}
/*纵向滚动条向上的三角形小图标 鼠标按下*/
QScrollBar::up-arrow:vertical:pressed {
image: url(scrollbar/scrollbar_arrowup_highlight.png);
}
/*横向滚动条左边的三角形小图标 鼠标按下*/
QScrollBar::left-arrow:horizontal:pressed {
image: url(scrollbar/scrollbar_arrowleft_highlight.png);
}
/*纵向滚动条下面三角形部分*/
QScrollBar::add-line:vertical {
height: 12px;
width: 10px;
background: transparent;
subcontrol-position: bottom;
}
/*横向滚动条右边的三角形部分*/
QScrollBar::add-line:horizontal {
height: 10px;
width: 12px;
background: transparent;
subcontrol-position: right;
}
/*纵向滚动条下面三角形图标*/
QScrollBar::down-arrow:vertical {
image: url(scrollbar/scrollbar_arrowdown_normal.png);
}
/*横向滚动条右侧三角形图标*/
QScrollBar::right-arrow:horizontal {
image: url(scrollbar/scrollbar_arrowright_normal.png);
}
/*纵向滚动条下面三角形图标 鼠标悬停*/
QScrollBar::down-arrow:vertical:hover {
image: url(scrollbar/scrollbar_arrowdown_down.png);
}
/*横向滚动条右侧三角形图标 鼠标悬停*/
QScrollBar::right-arrow:horizontal:hover {
image: url(scrollbar/scrollbar_arrowright_down.png);
}
/*纵向滚动条下面三角形图标 鼠标按下*/
QScrollBar::down-arrow:vertical:pressed {
image: url(scrollbar/scrollbar_arrowdown_highlight.png);
}
/*横向滚动条右侧三角形图标 鼠标按下*/
QScrollBar::right-arrow:horizontal:pressed {
image: url(scrollbar/scrollbar_arrowright_highlight.png);
/*QScrollBar Style*/
/*纵向滚动条*/
QScrollBar:vertical {
background: transparent; /*背景透明*/
width: 10px; /*宽度*/
margin: 0px 0px 0px 0px; /**/
padding-top: 12px; /*距离上面12px*/
padding-bottom: 12px; /*距离底部12px*/
}
/*横向滚动条*/
QScrollBar:horizontal {
background: transparent;
height: 10px; /*高度*/
margin: 0px 0px 0px 0px;
padding-left: 12px; /*距离左边12px*/
padding-right: 12px; /*距离右边12px*/
}
/*当鼠标放到纵向或者横向滚动条上面时*/
QScrollBar:vertical:hover,QScrollBar:horizontal:hover {
background: rgba(0, 0, 0, 30); /*修改背景透明度 30*/
border-radius: 5px; /*圆角*/
}
/*纵向滚动条上面的滑块*/
QScrollBar::handle:vertical {
background: rgba(0, 0, 0, 50);
width: 10px;
border-radius: 5px;
border: none;
}
/*横向滚动条上面的滑块*/
QScrollBar::handle:horizontal {
background: rgba(0, 0, 0, 50);
height: 10px;
border-radius: 5px;
border: none;
}
/*当鼠标放到滚动条滑块上面时改变透明度实现颜色的深浅变化*/
QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover {
background: rgba(0, 0, 0, 100);
}
/*纵向滚动条下部分块*/
QScrollBar::add-page:vertical {
width: 10px;
background: transparent;
}
/*横向滚动条后面部分块*/
QScrollBar::add-page:horizontal {
height: 10px;
background: transparent;
}
/*纵向滚动条上面部分块*/
QScrollBar::sub-page:vertical {
width: 10px;
background: transparent;
}
/*横向滚动条左部分块*/
QScrollBar::sub-page:horizontal {
height: 10px;
background: transparent;
}
/*纵向滚动条顶部三角形位置*/
QScrollBar::sub-line:vertical {
height: 12px;
width: 10px;
background: transparent;
subcontrol-position: top;
}
/*横向滚动条左侧三角形位置*/
QScrollBar::sub-line:horizontal {
height: 10px;
width: 12px;
background: transparent;
subcontrol-position: left;
}
/*纵向滚动条向上的三角形小图标*/
QScrollBar::up-arrow:vertical {
image: url(scrollbar/scrollbar_arrowup_normal.png);
}
/*横向滚动条左边的三角形小图标*/
QScrollBar::left-arrow:horizontal {
image: url(scrollbar/scrollbar_arrowleft_normal.png);
}
/*纵向滚动条向上的三角形小图标 鼠标悬停*/
QScrollBar::up-arrow:vertical:hover {
image: url(scrollbar/scrollbar_arrowup_down.png);
}
/*横向滚动条左边的三角形小图标 鼠标悬停*/
QScrollBar::left-arrow:horizontal:hover {
image: url(scrollbar/scrollbar_arrowleft_down.png);
}
/*纵向滚动条向上的三角形小图标 鼠标按下*/
QScrollBar::up-arrow:vertical:pressed {
image: url(scrollbar/scrollbar_arrowup_highlight.png);
}
/*横向滚动条左边的三角形小图标 鼠标按下*/
QScrollBar::left-arrow:horizontal:pressed {
image: url(scrollbar/scrollbar_arrowleft_highlight.png);
}
/*纵向滚动条下面三角形部分*/
QScrollBar::add-line:vertical {
height: 12px;
width: 10px;
background: transparent;
subcontrol-position: bottom;
}
/*横向滚动条右边的三角形部分*/
QScrollBar::add-line:horizontal {
height: 10px;
width: 12px;
background: transparent;
subcontrol-position: right;
}
/*纵向滚动条下面三角形图标*/
QScrollBar::down-arrow:vertical {
image: url(scrollbar/scrollbar_arrowdown_normal.png);
}
/*横向滚动条右侧三角形图标*/
QScrollBar::right-arrow:horizontal {
image: url(scrollbar/scrollbar_arrowright_normal.png);
}
/*纵向滚动条下面三角形图标 鼠标悬停*/
QScrollBar::down-arrow:vertical:hover {
image: url(scrollbar/scrollbar_arrowdown_down.png);
}
/*横向滚动条右侧三角形图标 鼠标悬停*/
QScrollBar::right-arrow:horizontal:hover {
image: url(scrollbar/scrollbar_arrowright_down.png);
}
/*纵向滚动条下面三角形图标 鼠标按下*/
QScrollBar::down-arrow:vertical:pressed {
image: url(scrollbar/scrollbar_arrowdown_highlight.png);
}
/*横向滚动条右侧三角形图标 鼠标按下*/
QScrollBar::right-arrow:horizontal:pressed {
image: url(scrollbar/scrollbar_arrowright_highlight.png);
}

View file

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View file

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View file

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View file

Before

Width:  |  Height:  |  Size: 125 B

After

Width:  |  Height:  |  Size: 125 B

View file

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

View file

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

View file

Before

Width:  |  Height:  |  Size: 119 B

After

Width:  |  Height:  |  Size: 119 B

View file

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View file

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

31
美化/README.md Normal file
View file

@ -0,0 +1,31 @@
# 界面美化
## QPushButton
### 1. [按钮常见样式](QPushButton/按钮常见样式.py)
主要改变背景颜色、鼠标按下颜色、鼠标悬停颜色、圆角、圆形、文字颜色
![截图](QPushButton/ScreenShot/按钮常见样式.gif)
### 2. [按钮进度动画](QPushButton/按钮进度动画)
1. [按钮字体旋转动画](QPushButton/按钮进度动画/按钮字体旋转动画.py)
利用字体使用FontAwesome字体来显示一个圆形进度条然后利用旋转动画
![截图](QPushButton/按钮进度动画/ScreenShot/按钮字体旋转动画.gif)
2. [按钮底部线条动画](QPushButton/按钮进度动画/按钮底部线条动画.py)
在按钮下方画一条线,根据百分值绘制
![截图](QPushButton/按钮进度动画/ScreenShot/按钮底部线条动画.gif)
## QLabel
1. [圆形图片](QLabel/圆形图片.py)
使用`QPainter`的`setClipPath`方法结合`QPainterPath`对图片进行裁剪从而实现圆形图片。
![截图](QLabel/ScreenShot/圆形图片.png)

View file

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB

View file

Before

Width:  |  Height:  |  Size: 821 KiB

After

Width:  |  Height:  |  Size: 821 KiB

Some files were not shown because too many files have changed in this diff Show more