整理美化部分目录
|
@ -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//\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//\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//\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/\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/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/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/\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/\u6D88\u606F\u5BF9\u8BDD\u6846\u5012\u8BA1\u65F6\u5173\u95ED.py=utf-8
|
||||||
encoding//\u7A97\u53E3/\u7A97\u53E3\u91CD\u542F.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/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/CustomWidget.py=utf-8
|
||||||
encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/test.py=utf-8
|
encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/test.py=utf-8
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
# QLabel圆形头像
|
|
||||||
|
|
||||||
一种比较好的方法制作圆形头像
|
|
||||||
|
|
||||||
### 简单说明
|
|
||||||
该方法使用QPainter的 setClipPath 方法结合QPainterPath对图片进行裁剪。
|
|
||||||
|
|
||||||
截图
|
|
||||||
|
|
||||||
![1](ScreenShot/1.png)
|
|
|
@ -1,10 +0,0 @@
|
||||||
# QPushButton 加载动画
|
|
||||||
|
|
||||||
### 简单说明
|
|
||||||
- 1.第一种是利用字体,使用FontAwesome字体来显示一个圆形进度条,然后利用旋转动画
|
|
||||||
- 2.第二种是在按钮下方画一条线,根据百分值绘制
|
|
||||||
|
|
||||||
截图
|
|
||||||
|
|
||||||
![1](ScreenShot/1.gif)
|
|
||||||
![1](ScreenShot/2.gif)
|
|
|
@ -1,8 +0,0 @@
|
||||||
# QPushButton 按钮 QSS 美化样式
|
|
||||||
|
|
||||||
主要改变背景颜色、鼠标按下颜色、鼠标悬停颜色、圆角、圆形、文字颜色
|
|
||||||
|
|
||||||
效果图:
|
|
||||||
|
|
||||||
### [ButtonHover.py](ButtonHover.py)
|
|
||||||
![ButtonHover](ScreenShot/ButtonHover.gif)
|
|
|
@ -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)
|
|
|
@ -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.各类进度条](各类进度条/)
|
|
|
@ -1,117 +1,117 @@
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月30日
|
Created on 2018年1月30日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: CalendarWidget
|
@file: CalendarWidget
|
||||||
@description: 日历
|
@description: 日历
|
||||||
'''
|
'''
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QCalendarWidget
|
from PyQt5.QtWidgets import QApplication, QCalendarWidget
|
||||||
|
|
||||||
|
|
||||||
StyleSheet = '''
|
StyleSheet = '''
|
||||||
/*顶部导航区域*/
|
/*顶部导航区域*/
|
||||||
#qt_calendar_navigationbar {
|
#qt_calendar_navigationbar {
|
||||||
background-color: rgb(0, 188, 212);
|
background-color: rgb(0, 188, 212);
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*上一个月按钮和下一个月按钮(从源码里找到的objectName)*/
|
/*上一个月按钮和下一个月按钮(从源码里找到的objectName)*/
|
||||||
#qt_calendar_prevmonth, #qt_calendar_nextmonth {
|
#qt_calendar_prevmonth, #qt_calendar_nextmonth {
|
||||||
border: none; /*去掉边框*/
|
border: none; /*去掉边框*/
|
||||||
margin-top: 64px;
|
margin-top: 64px;
|
||||||
color: white;
|
color: white;
|
||||||
min-width: 36px;
|
min-width: 36px;
|
||||||
max-width: 36px;
|
max-width: 36px;
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
max-height: 36px;
|
max-height: 36px;
|
||||||
border-radius: 18px; /*看来近似椭圆*/
|
border-radius: 18px; /*看来近似椭圆*/
|
||||||
font-weight: bold; /*字体加粗*/
|
font-weight: bold; /*字体加粗*/
|
||||||
qproperty-icon: none; /*去掉默认的方向键图片,当然也可以自定义*/
|
qproperty-icon: none; /*去掉默认的方向键图片,当然也可以自定义*/
|
||||||
background-color: transparent;/*背景颜色透明*/
|
background-color: transparent;/*背景颜色透明*/
|
||||||
}
|
}
|
||||||
#qt_calendar_prevmonth {
|
#qt_calendar_prevmonth {
|
||||||
qproperty-text: "<"; /*修改按钮的文字*/
|
qproperty-text: "<"; /*修改按钮的文字*/
|
||||||
}
|
}
|
||||||
#qt_calendar_nextmonth {
|
#qt_calendar_nextmonth {
|
||||||
qproperty-text: ">";
|
qproperty-text: ">";
|
||||||
}
|
}
|
||||||
#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover {
|
#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover {
|
||||||
background-color: rgba(225, 225, 225, 100);
|
background-color: rgba(225, 225, 225, 100);
|
||||||
}
|
}
|
||||||
#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed {
|
#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed {
|
||||||
background-color: rgba(235, 235, 235, 100);
|
background-color: rgba(235, 235, 235, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*年,月控件*/
|
/*年,月控件*/
|
||||||
#qt_calendar_yearbutton, #qt_calendar_monthbutton {
|
#qt_calendar_yearbutton, #qt_calendar_monthbutton {
|
||||||
color: white;
|
color: white;
|
||||||
margin: 18px;
|
margin: 18px;
|
||||||
min-width: 60px;
|
min-width: 60px;
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
}
|
}
|
||||||
#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover {
|
#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover {
|
||||||
background-color: rgba(225, 225, 225, 100);
|
background-color: rgba(225, 225, 225, 100);
|
||||||
}
|
}
|
||||||
#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed {
|
#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed {
|
||||||
background-color: rgba(235, 235, 235, 100);
|
background-color: rgba(235, 235, 235, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*年份输入框*/
|
/*年份输入框*/
|
||||||
#qt_calendar_yearedit {
|
#qt_calendar_yearedit {
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
color: white;
|
color: white;
|
||||||
background: transparent;/*让输入框背景透明*/
|
background: transparent;/*让输入框背景透明*/
|
||||||
}
|
}
|
||||||
#qt_calendar_yearedit::up-button { /*往上的按钮*/
|
#qt_calendar_yearedit::up-button { /*往上的按钮*/
|
||||||
width: 20px;
|
width: 20px;
|
||||||
subcontrol-position: right;/*移动到右边*/
|
subcontrol-position: right;/*移动到右边*/
|
||||||
}
|
}
|
||||||
#qt_calendar_yearedit::down-button { /*往下的按钮*/
|
#qt_calendar_yearedit::down-button { /*往下的按钮*/
|
||||||
width: 20px;
|
width: 20px;
|
||||||
subcontrol-position: left; /*移动到左边去*/
|
subcontrol-position: left; /*移动到左边去*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*月份选择菜单*/
|
/*月份选择菜单*/
|
||||||
CalendarWidget QToolButton QMenu {
|
CalendarWidget QToolButton QMenu {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
CalendarWidget QToolButton QMenu::item {
|
CalendarWidget QToolButton QMenu::item {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
CalendarWidget QToolButton QMenu::item:selected:enabled {
|
CalendarWidget QToolButton QMenu::item:selected:enabled {
|
||||||
background-color: rgb(230, 230, 230);
|
background-color: rgb(230, 230, 230);
|
||||||
}
|
}
|
||||||
CalendarWidget QToolButton::menu-indicator {
|
CalendarWidget QToolButton::menu-indicator {
|
||||||
/*image: none;去掉月份选择下面的小箭头*/
|
/*image: none;去掉月份选择下面的小箭头*/
|
||||||
subcontrol-position: right center;/*右边居中*/
|
subcontrol-position: right center;/*右边居中*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*下方的日历表格*/
|
/*下方的日历表格*/
|
||||||
#qt_calendar_calendarview {
|
#qt_calendar_calendarview {
|
||||||
outline: 0px;/*去掉选中后的虚线框*/
|
outline: 0px;/*去掉选中后的虚线框*/
|
||||||
selection-background-color: rgb(0, 188, 212); /*选中背景颜色*/
|
selection-background-color: rgb(0, 188, 212); /*选中背景颜色*/
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
class CalendarWidget(QCalendarWidget):
|
class CalendarWidget(QCalendarWidget):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(CalendarWidget, self).__init__(*args, **kwargs)
|
super(CalendarWidget, self).__init__(*args, **kwargs)
|
||||||
# 隐藏左边的序号
|
# 隐藏左边的序号
|
||||||
self.setVerticalHeaderFormat(self.NoVerticalHeader)
|
self.setVerticalHeaderFormat(self.NoVerticalHeader)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet(StyleSheet)
|
app.setStyleSheet(StyleSheet)
|
||||||
w = CalendarWidget()
|
w = CalendarWidget()
|
||||||
w.show()
|
w.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,10 +1,10 @@
|
||||||
# QCalendarWidget 日历控件 QSS 美化样式
|
# QCalendarWidget 日历控件 QSS 美化样式
|
||||||
|
|
||||||
主要改变顶部背景颜色和高度,上下月按钮、月份选择、年选择、菜单
|
主要改变顶部背景颜色和高度,上下月按钮、月份选择、年选择、菜单
|
||||||
|
|
||||||
详细美化都在代码里的QSS中注释了
|
详细美化都在代码里的QSS中注释了
|
||||||
|
|
||||||
效果图:
|
效果图:
|
||||||
|
|
||||||
### [CalendarWidget.py](CalendarWidget.py)
|
### [CalendarWidget.py](CalendarWidget.py)
|
||||||
![CalendarWidget](ScreenShot/CalendarWidget.gif)
|
![CalendarWidget](ScreenShot/CalendarWidget.gif)
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
@ -1,82 +1,82 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月26日
|
Created on 2018年1月26日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: FileSystemModel
|
@file: FileSystemModel
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QFileInfo
|
from PyQt5.QtCore import QFileInfo
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import QFileSystemModel, QFileIconProvider, QApplication,\
|
from PyQt5.QtWidgets import QFileSystemModel, QFileIconProvider, QApplication,\
|
||||||
QTreeView
|
QTreeView
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
# 图标提供类
|
# 图标提供类
|
||||||
|
|
||||||
|
|
||||||
class FileIconProvider(QFileIconProvider):
|
class FileIconProvider(QFileIconProvider):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(FileIconProvider, self).__init__(*args, **kwargs)
|
super(FileIconProvider, self).__init__(*args, **kwargs)
|
||||||
self.DirIcon = QIcon("icons/folder.png")
|
self.DirIcon = QIcon("icons/folder.png")
|
||||||
self.TxtIcon = QIcon("icons/file.png")
|
self.TxtIcon = QIcon("icons/file.png")
|
||||||
|
|
||||||
def icon(self, type_info):
|
def icon(self, type_info):
|
||||||
'''
|
'''
|
||||||
:param fileInfo: 参考http://doc.qt.io/qt-5/qfileinfo.html
|
:param fileInfo: 参考http://doc.qt.io/qt-5/qfileinfo.html
|
||||||
'''
|
'''
|
||||||
if isinstance(type_info, QFileInfo):
|
if isinstance(type_info, QFileInfo):
|
||||||
# 如果type_info是QFileInfo类型则用getInfoIcon来返回图标
|
# 如果type_info是QFileInfo类型则用getInfoIcon来返回图标
|
||||||
return self.getInfoIcon(type_info)
|
return self.getInfoIcon(type_info)
|
||||||
# 如果type_info是QFileIconProvider自身的IconType枚举类型则执行下面的方法
|
# 如果type_info是QFileIconProvider自身的IconType枚举类型则执行下面的方法
|
||||||
# 这里只能自定义通用的几种类型,参考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum
|
# 这里只能自定义通用的几种类型,参考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum
|
||||||
'''
|
'''
|
||||||
QFileIconProvider::Computer 0
|
QFileIconProvider::Computer 0
|
||||||
QFileIconProvider::Desktop 1
|
QFileIconProvider::Desktop 1
|
||||||
QFileIconProvider::Trashcan 2
|
QFileIconProvider::Trashcan 2
|
||||||
QFileIconProvider::Network 3
|
QFileIconProvider::Network 3
|
||||||
QFileIconProvider::Drive 4
|
QFileIconProvider::Drive 4
|
||||||
QFileIconProvider::Folder 5
|
QFileIconProvider::Folder 5
|
||||||
QFileIconProvider::File 6
|
QFileIconProvider::File 6
|
||||||
'''
|
'''
|
||||||
if type_info == QFileIconProvider.Folder:
|
if type_info == QFileIconProvider.Folder:
|
||||||
# 如果是文件夹
|
# 如果是文件夹
|
||||||
return self.DirIcon
|
return self.DirIcon
|
||||||
return super(FileIconProvider, self).icon(type_info)
|
return super(FileIconProvider, self).icon(type_info)
|
||||||
|
|
||||||
def getInfoIcon(self, type_info):
|
def getInfoIcon(self, type_info):
|
||||||
if type_info.isDir(): # 文件夹
|
if type_info.isDir(): # 文件夹
|
||||||
return self.DirIcon
|
return self.DirIcon
|
||||||
if type_info.isFile() and type_info.suffix() == "txt": # 文件并且是txt
|
if type_info.isFile() and type_info.suffix() == "txt": # 文件并且是txt
|
||||||
return self.TxtIcon
|
return self.TxtIcon
|
||||||
return super(FileIconProvider, self).icon(type_info)
|
return super(FileIconProvider, self).icon(type_info)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
model = QFileSystemModel()
|
model = QFileSystemModel()
|
||||||
model.setIconProvider(FileIconProvider()) # 设置为自定义的图标提供类
|
model.setIconProvider(FileIconProvider()) # 设置为自定义的图标提供类
|
||||||
model.setRootPath("")
|
model.setRootPath("")
|
||||||
tree = QTreeView()
|
tree = QTreeView()
|
||||||
tree.setModel(model)
|
tree.setModel(model)
|
||||||
|
|
||||||
tree.setAnimated(False)
|
tree.setAnimated(False)
|
||||||
tree.setIndentation(20)
|
tree.setIndentation(20)
|
||||||
tree.setSortingEnabled(True)
|
tree.setSortingEnabled(True)
|
||||||
|
|
||||||
tree.setWindowTitle("Dir View")
|
tree.setWindowTitle("Dir View")
|
||||||
tree.resize(640, 480)
|
tree.resize(640, 480)
|
||||||
tree.show()
|
tree.show()
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,11 +1,11 @@
|
||||||
# QFileSystemModel 自定义图标
|
# QFileSystemModel 自定义图标
|
||||||
|
|
||||||
使用QFileSystemModel.setIconProvider(QFileIconProvider)来设置图标提供类
|
使用QFileSystemModel.setIconProvider(QFileIconProvider)来设置图标提供类
|
||||||
|
|
||||||
通过重写QFileIconProvider的icon方法来决定返回什么样的图标
|
通过重写QFileIconProvider的icon方法来决定返回什么样的图标
|
||||||
|
|
||||||
见需求 [Issues#2](https://github.com/892768447/PyQt/issues/2)
|
见需求 [Issues#2](https://github.com/892768447/PyQt/issues/2)
|
||||||
|
|
||||||
截图
|
截图
|
||||||
|
|
||||||
![1](ScreenShot/1.png)
|
![1](ScreenShot/1.png)
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
@ -1,75 +1,75 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月20日
|
Created on 2018年1月20日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: CircleLabel
|
@file: CircleLabel
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QPixmap, QPainter, QPainterPath
|
from PyQt5.QtGui import QPixmap, QPainter, QPainterPath
|
||||||
from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout
|
from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
|
|
||||||
class Label(QLabel):
|
class Label(QLabel):
|
||||||
|
|
||||||
def __init__(self, *args, antialiasing=True, **kwargs):
|
def __init__(self, *args, antialiasing=True, **kwargs):
|
||||||
super(Label, self).__init__(*args, **kwargs)
|
super(Label, self).__init__(*args, **kwargs)
|
||||||
self.Antialiasing = antialiasing
|
self.Antialiasing = antialiasing
|
||||||
self.setMaximumSize(200, 200)
|
self.setMaximumSize(200, 200)
|
||||||
self.setMinimumSize(200, 200)
|
self.setMinimumSize(200, 200)
|
||||||
self.radius = 100
|
self.radius = 100
|
||||||
|
|
||||||
#####################核心实现#########################
|
#####################核心实现#########################
|
||||||
self.target = QPixmap(self.size()) # 大小和控件一样
|
self.target = QPixmap(self.size()) # 大小和控件一样
|
||||||
self.target.fill(Qt.transparent) # 填充背景为透明
|
self.target.fill(Qt.transparent) # 填充背景为透明
|
||||||
|
|
||||||
p = QPixmap("head.jpg").scaled( # 加载图片并缩放和控件一样大
|
p = QPixmap("Images/head.jpg").scaled( # 加载图片并缩放和控件一样大
|
||||||
200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
||||||
|
|
||||||
painter = QPainter(self.target)
|
painter = QPainter(self.target)
|
||||||
if self.Antialiasing:
|
if self.Antialiasing:
|
||||||
# 抗锯齿
|
# 抗锯齿
|
||||||
painter.setRenderHint(QPainter.Antialiasing, True)
|
painter.setRenderHint(QPainter.Antialiasing, True)
|
||||||
painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
|
painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
|
||||||
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
|
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
|
||||||
|
|
||||||
# painter.setPen(# 测试圆圈
|
# painter.setPen(# 测试圆圈
|
||||||
# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
|
# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
|
||||||
path = QPainterPath()
|
path = QPainterPath()
|
||||||
path.addRoundedRect(
|
path.addRoundedRect(
|
||||||
0, 0, self.width(), self.height(), self.radius, self.radius)
|
0, 0, self.width(), self.height(), self.radius, self.radius)
|
||||||
#**** 切割为圆形 ****#
|
#**** 切割为圆形 ****#
|
||||||
painter.setClipPath(path)
|
painter.setClipPath(path)
|
||||||
# painter.drawPath(path) # 测试圆圈
|
# painter.drawPath(path) # 测试圆圈
|
||||||
|
|
||||||
painter.drawPixmap(0, 0, p)
|
painter.drawPixmap(0, 0, p)
|
||||||
self.setPixmap(self.target)
|
self.setPixmap(self.target)
|
||||||
#####################核心实现#########################
|
#####################核心实现#########################
|
||||||
|
|
||||||
|
|
||||||
class Window(QWidget):
|
class Window(QWidget):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Window, self).__init__(*args, **kwargs)
|
super(Window, self).__init__(*args, **kwargs)
|
||||||
layout = QHBoxLayout(self)
|
layout = QHBoxLayout(self)
|
||||||
layout.addWidget(Label(self))
|
layout.addWidget(Label(self))
|
||||||
layout.addWidget(Label(self, antialiasing=False))
|
layout.addWidget(Label(self, antialiasing=False))
|
||||||
self.setStyleSheet("background: black;")
|
self.setStyleSheet("background: black;")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
w = Window()
|
w = Window()
|
||||||
w.show()
|
w.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,11 +1,11 @@
|
||||||
# 消息提示框的按钮和图标美化
|
# 消息提示框的按钮和图标美化
|
||||||
|
|
||||||
### [1.方案一](方案一/)
|
### [1.方案一](方案一/)
|
||||||
- 1.1 该方案使用dialogbuttonbox-buttons-have-icons: 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.2 再利用dialog-xx-icon: url(); 来设置自定义的图标, 具体参考[list-of-icons](http://doc.qt.io/qt-5/stylesheet-reference.html#list-of-icons)
|
||||||
- 1.3 缺点 部分按钮图标无效,无法自定义不同按钮的颜色
|
- 1.3 缺点 部分按钮图标无效,无法自定义不同按钮的颜色
|
||||||
|
|
||||||
### [2.方案二](方案二/)
|
### [2.方案二](方案二/)
|
||||||
- 2.1 采用样式表中的属性选择器 QPushButton[text="xxx"] 可以根据按钮中的文字来区分
|
- 2.1 采用样式表中的属性选择器 QPushButton[text="xxx"] 可以根据按钮中的文字来区分
|
||||||
- 2.2 在利用属性样式qproperty-icon: url();来设置自定义图标
|
- 2.2 在利用属性样式qproperty-icon: url();来设置自定义图标
|
||||||
- 2.3 解决方案一的缺点
|
- 2.3 解决方案一的缺点
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 7 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 9 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
|
@ -1,7 +1,7 @@
|
||||||
# 方案一
|
# 方案一
|
||||||
|
|
||||||
截图
|
截图
|
||||||
![critical](ScreenShot/critical.png)
|
![critical](ScreenShot/critical.png)
|
||||||
![information](ScreenShot/information.png)
|
![information](ScreenShot/information.png)
|
||||||
![question](ScreenShot/question.png)
|
![question](ScreenShot/question.png)
|
||||||
![warning](ScreenShot/warning.png)
|
![warning](ScreenShot/warning.png)
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
@ -1,40 +1,40 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: critical
|
@file: critical
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''QDialogButtonBox {
|
app.setStyleSheet('''QDialogButtonBox {
|
||||||
dialogbuttonbox-buttons-have-icons: 1;
|
dialogbuttonbox-buttons-have-icons: 1;
|
||||||
dialog-ok-icon: url(../icons/Ok.png);
|
dialog-ok-icon: url(../icons/Ok.png);
|
||||||
dialog-open-icon: url(../icons/Open.png);
|
dialog-open-icon: url(../icons/Open.png);
|
||||||
dialog-save-icon: url(../icons/Save.png);
|
dialog-save-icon: url(../icons/Save.png);
|
||||||
dialog-cancel-icon: url(../icons/Cancel.png);
|
dialog-cancel-icon: url(../icons/Cancel.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-critical-icon: url(../icons/Close.png);
|
messagebox-critical-icon: url(../icons/Close.png);
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.critical(None, "提示critical", "消息",
|
QMessageBox.critical(None, "提示critical", "消息",
|
||||||
QMessageBox.Ok |
|
QMessageBox.Ok |
|
||||||
QMessageBox.Open |
|
QMessageBox.Open |
|
||||||
QMessageBox.Save |
|
QMessageBox.Save |
|
||||||
QMessageBox.Cancel)
|
QMessageBox.Cancel)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,40 +1,40 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: information
|
@file: information
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''QDialogButtonBox {
|
app.setStyleSheet('''QDialogButtonBox {
|
||||||
dialogbuttonbox-buttons-have-icons: 1;
|
dialogbuttonbox-buttons-have-icons: 1;
|
||||||
dialog-close-icon: url(../icons/Close.png);
|
dialog-close-icon: url(../icons/Close.png);
|
||||||
dialog-discard-icon: url(../icons/Discard.png);
|
dialog-discard-icon: url(../icons/Discard.png);
|
||||||
dialog-apply-icon: url(../icons/Apply.png);
|
dialog-apply-icon: url(../icons/Apply.png);
|
||||||
dialog-reset-icon: url(../icons/Reset.png);
|
dialog-reset-icon: url(../icons/Reset.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-information-icon: url(../icons/Ok.png);
|
messagebox-information-icon: url(../icons/Ok.png);
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.information(None, "提示information", "消息",
|
QMessageBox.information(None, "提示information", "消息",
|
||||||
QMessageBox.Close |
|
QMessageBox.Close |
|
||||||
QMessageBox.Discard |
|
QMessageBox.Discard |
|
||||||
QMessageBox.Apply |
|
QMessageBox.Apply |
|
||||||
QMessageBox.Reset)
|
QMessageBox.Reset)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,39 +1,39 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: question
|
@file: question
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''QDialogButtonBox {
|
app.setStyleSheet('''QDialogButtonBox {
|
||||||
dialogbuttonbox-buttons-have-icons: 1;
|
dialogbuttonbox-buttons-have-icons: 1;
|
||||||
dialog-help-icon: url(../icons/Help.png);
|
dialog-help-icon: url(../icons/Help.png);
|
||||||
dialog-yes-icon: url(../icons/Yes.png);
|
dialog-yes-icon: url(../icons/Yes.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-question-icon: url(../icons/Ok.png);
|
messagebox-question-icon: url(../icons/Ok.png);
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.question(None, "提示question", "消息",
|
QMessageBox.question(None, "提示question", "消息",
|
||||||
QMessageBox.RestoreDefaults |
|
QMessageBox.RestoreDefaults |
|
||||||
QMessageBox.Help |
|
QMessageBox.Help |
|
||||||
QMessageBox.SaveAll |
|
QMessageBox.SaveAll |
|
||||||
QMessageBox.Yes |
|
QMessageBox.Yes |
|
||||||
QMessageBox.YesToAll)
|
QMessageBox.YesToAll)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,39 +1,39 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: warning
|
@file: warning
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''QDialogButtonBox {
|
app.setStyleSheet('''QDialogButtonBox {
|
||||||
dialogbuttonbox-buttons-have-icons: 1;
|
dialogbuttonbox-buttons-have-icons: 1;
|
||||||
dialog-no-icon: url(../icons/No.png);
|
dialog-no-icon: url(../icons/No.png);
|
||||||
dialog-abort-icon: url(../icons/Abort.png);
|
dialog-abort-icon: url(../icons/Abort.png);
|
||||||
dialog-retry-icon: url(../icons/Retry.png);
|
dialog-retry-icon: url(../icons/Retry.png);
|
||||||
dialog-ignore-icon: url(../icons/Ignore.png);
|
dialog-ignore-icon: url(../icons/Ignore.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-warning-icon: url(../icons/Ok.png);
|
messagebox-warning-icon: url(../icons/Ok.png);
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.warning(None, "提示warning", "消息",
|
QMessageBox.warning(None, "提示warning", "消息",
|
||||||
QMessageBox.No |
|
QMessageBox.No |
|
||||||
QMessageBox.NoToAll |
|
QMessageBox.NoToAll |
|
||||||
QMessageBox.Abort |
|
QMessageBox.Abort |
|
||||||
QMessageBox.Retry |
|
QMessageBox.Retry |
|
||||||
QMessageBox.Ignore)
|
QMessageBox.Ignore)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,7 +1,7 @@
|
||||||
# 方案二
|
# 方案二
|
||||||
|
|
||||||
截图
|
截图
|
||||||
![critical](ScreenShot/critical.png)
|
![critical](ScreenShot/critical.png)
|
||||||
![information](ScreenShot/information.png)
|
![information](ScreenShot/information.png)
|
||||||
![question](ScreenShot/question.png)
|
![question](ScreenShot/question.png)
|
||||||
![warning](ScreenShot/warning.png)
|
![warning](ScreenShot/warning.png)
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -1,71 +1,71 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: critical
|
@file: critical
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''
|
app.setStyleSheet('''
|
||||||
QPushButton[text="OK"] {
|
QPushButton[text="OK"] {
|
||||||
background: red;
|
background: red;
|
||||||
qproperty-icon: url(../icons/Ok.png);
|
qproperty-icon: url(../icons/Ok.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="OK"]:hover {
|
QPushButton[text="OK"]:hover {
|
||||||
background: darkRed;
|
background: darkRed;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Open"] {
|
QPushButton[text="Open"] {
|
||||||
background: green;
|
background: green;
|
||||||
qproperty-icon: url(../icons/Open.png);
|
qproperty-icon: url(../icons/Open.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Open"]:hover {
|
QPushButton[text="Open"]:hover {
|
||||||
background: darkGreen;
|
background: darkGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Save"] {
|
QPushButton[text="Save"] {
|
||||||
background: blue;
|
background: blue;
|
||||||
qproperty-icon: url(../icons/Save.png);
|
qproperty-icon: url(../icons/Save.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Save"]:hover {
|
QPushButton[text="Save"]:hover {
|
||||||
background: darkBlue;
|
background: darkBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Cancel"] {
|
QPushButton[text="Cancel"] {
|
||||||
background: cyan;
|
background: cyan;
|
||||||
qproperty-icon: url(../icons/Cancel.png);
|
qproperty-icon: url(../icons/Cancel.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Cancel"]:hover {
|
QPushButton[text="Cancel"]:hover {
|
||||||
background: darkCyan;
|
background: darkCyan;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-critical-icon: url(../icons/Close.png);
|
messagebox-critical-icon: url(../icons/Close.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox QPushButton {
|
QMessageBox QPushButton {
|
||||||
min-width: 95px;
|
min-width: 95px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.critical(None, "提示critical", "消息",
|
QMessageBox.critical(None, "提示critical", "消息",
|
||||||
QMessageBox.Ok |
|
QMessageBox.Ok |
|
||||||
QMessageBox.Open |
|
QMessageBox.Open |
|
||||||
QMessageBox.Save |
|
QMessageBox.Save |
|
||||||
QMessageBox.Cancel)
|
QMessageBox.Cancel)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,71 +1,71 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: information
|
@file: information
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''
|
app.setStyleSheet('''
|
||||||
QPushButton[text="Close"] {
|
QPushButton[text="Close"] {
|
||||||
background: red;
|
background: red;
|
||||||
qproperty-icon: url(../icons/Close.png);
|
qproperty-icon: url(../icons/Close.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Close"]:hover {
|
QPushButton[text="Close"]:hover {
|
||||||
background: darkRed;
|
background: darkRed;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Discard"] {
|
QPushButton[text="Discard"] {
|
||||||
background: green;
|
background: green;
|
||||||
qproperty-icon: url(../icons/Discard.png);
|
qproperty-icon: url(../icons/Discard.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Discard"]:hover {
|
QPushButton[text="Discard"]:hover {
|
||||||
background: darkGreen;
|
background: darkGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Apply"] {
|
QPushButton[text="Apply"] {
|
||||||
background: blue;
|
background: blue;
|
||||||
qproperty-icon: url(../icons/Apply.png);
|
qproperty-icon: url(../icons/Apply.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Apply"]:hover {
|
QPushButton[text="Apply"]:hover {
|
||||||
background: darkBlue;
|
background: darkBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Reset"] {
|
QPushButton[text="Reset"] {
|
||||||
background: cyan;
|
background: cyan;
|
||||||
qproperty-icon: url(../icons/Reset.png);
|
qproperty-icon: url(../icons/Reset.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Reset"]:hover {
|
QPushButton[text="Reset"]:hover {
|
||||||
background: darkCyan;
|
background: darkCyan;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-information-icon: url(../icons/Close.png);
|
messagebox-information-icon: url(../icons/Close.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox QPushButton {
|
QMessageBox QPushButton {
|
||||||
min-width: 95px;
|
min-width: 95px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.information(None, "提示information", "消息",
|
QMessageBox.information(None, "提示information", "消息",
|
||||||
QMessageBox.Close |
|
QMessageBox.Close |
|
||||||
QMessageBox.Discard |
|
QMessageBox.Discard |
|
||||||
QMessageBox.Apply |
|
QMessageBox.Apply |
|
||||||
QMessageBox.Reset)
|
QMessageBox.Reset)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,80 +1,80 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: question
|
@file: question
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''
|
app.setStyleSheet('''
|
||||||
QPushButton[text="Restore Defaults"] {
|
QPushButton[text="Restore Defaults"] {
|
||||||
background: red;
|
background: red;
|
||||||
qproperty-icon: url(../icons/RestoreDefaults.png);
|
qproperty-icon: url(../icons/RestoreDefaults.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Restore Defaults"]:hover {
|
QPushButton[text="Restore Defaults"]:hover {
|
||||||
background: darkRed;
|
background: darkRed;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Help"] {
|
QPushButton[text="Help"] {
|
||||||
background: green;
|
background: green;
|
||||||
qproperty-icon: url(../icons/Help.png);
|
qproperty-icon: url(../icons/Help.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Help"]:hover {
|
QPushButton[text="Help"]:hover {
|
||||||
background: darkGreen;
|
background: darkGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Save All"] {
|
QPushButton[text="Save All"] {
|
||||||
background: blue;
|
background: blue;
|
||||||
qproperty-icon: url(../icons/SaveAll.png);
|
qproperty-icon: url(../icons/SaveAll.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Save All"]:hover {
|
QPushButton[text="Save All"]:hover {
|
||||||
background: darkBlue;
|
background: darkBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="&Yes"] {
|
QPushButton[text="&Yes"] {
|
||||||
background: cyan;
|
background: cyan;
|
||||||
qproperty-icon: url(../icons/Yes.png);
|
qproperty-icon: url(../icons/Yes.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="&Yes"]:hover {
|
QPushButton[text="&Yes"]:hover {
|
||||||
background: darkCyan;
|
background: darkCyan;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Yes to &All"] {
|
QPushButton[text="Yes to &All"] {
|
||||||
background: magenta;
|
background: magenta;
|
||||||
qproperty-icon: url(../icons/YesToAll.png);
|
qproperty-icon: url(../icons/YesToAll.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Yes to &All"]:hover {
|
QPushButton[text="Yes to &All"]:hover {
|
||||||
background: darkMegenta;
|
background: darkMegenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-question-icon: url(../icons/Close.png);
|
messagebox-question-icon: url(../icons/Close.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox QPushButton {
|
QMessageBox QPushButton {
|
||||||
min-width: 95px;
|
min-width: 95px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.question(None, "提示question", "消息",
|
QMessageBox.question(None, "提示question", "消息",
|
||||||
QMessageBox.RestoreDefaults |
|
QMessageBox.RestoreDefaults |
|
||||||
QMessageBox.Help |
|
QMessageBox.Help |
|
||||||
QMessageBox.SaveAll |
|
QMessageBox.SaveAll |
|
||||||
QMessageBox.Yes |
|
QMessageBox.Yes |
|
||||||
QMessageBox.YesToAll)
|
QMessageBox.YesToAll)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,84 +1,84 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月17日
|
Created on 2018年1月17日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: warning
|
@file: warning
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet('''
|
app.setStyleSheet('''
|
||||||
QPushButton[text="&No"] {
|
QPushButton[text="&No"] {
|
||||||
background: red;
|
background: red;
|
||||||
qproperty-icon: url(../icons/No.png);
|
qproperty-icon: url(../icons/No.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="&No"]:hover {
|
QPushButton[text="&No"]:hover {
|
||||||
background: darkRed;
|
background: darkRed;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="N&o to All"] {
|
QPushButton[text="N&o to All"] {
|
||||||
background: green;
|
background: green;
|
||||||
qproperty-icon: url(../icons/NoToAll.png);
|
qproperty-icon: url(../icons/NoToAll.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="N&o to All"]:hover {
|
QPushButton[text="N&o to All"]:hover {
|
||||||
background: darkGreen;
|
background: darkGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Abort"] {
|
QPushButton[text="Abort"] {
|
||||||
background: blue;
|
background: blue;
|
||||||
qproperty-icon: url(../icons/Abort.png);
|
qproperty-icon: url(../icons/Abort.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Abort"]:hover {
|
QPushButton[text="Abort"]:hover {
|
||||||
background: darkBlue;
|
background: darkBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Retry"] {
|
QPushButton[text="Retry"] {
|
||||||
background: cyan;
|
background: cyan;
|
||||||
qproperty-icon: url(../icons/Retry.png);
|
qproperty-icon: url(../icons/Retry.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Retry"]:hover {
|
QPushButton[text="Retry"]:hover {
|
||||||
background: darkCyan;
|
background: darkCyan;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton[text="Ignore"] {
|
QPushButton[text="Ignore"] {
|
||||||
background: magenta;
|
background: magenta;
|
||||||
qproperty-icon: url(../icons/Ignore.png);
|
qproperty-icon: url(../icons/Ignore.png);
|
||||||
}
|
}
|
||||||
QPushButton[text="Ignore"]:hover {
|
QPushButton[text="Ignore"]:hover {
|
||||||
background: darkMegenta;
|
background: darkMegenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox {
|
QMessageBox {
|
||||||
messagebox-warning-icon: url(../icons/No.png);
|
messagebox-warning-icon: url(../icons/No.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox QPushButton {
|
QMessageBox QPushButton {
|
||||||
min-width: 95px;
|
min-width: 95px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox QLabel {
|
QMessageBox QLabel {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
QMessageBox.warning(None, "提示warning", "消息",
|
QMessageBox.warning(None, "提示warning", "消息",
|
||||||
QMessageBox.No |
|
QMessageBox.No |
|
||||||
QMessageBox.NoToAll |
|
QMessageBox.NoToAll |
|
||||||
QMessageBox.Abort |
|
QMessageBox.Abort |
|
||||||
QMessageBox.Retry |
|
QMessageBox.Retry |
|
||||||
QMessageBox.Ignore)
|
QMessageBox.Ignore)
|
||||||
sys.exit()
|
sys.exit()
|
|
@ -1,105 +1,105 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月30日
|
Created on 2018年1月30日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: ProgressBar
|
@file: ProgressBar
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
from random import randint
|
from random import randint
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer
|
from PyQt5.QtCore import QTimer
|
||||||
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QProgressBar
|
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QProgressBar
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
StyleSheet = '''
|
StyleSheet = '''
|
||||||
/*设置红色进度条*/
|
/*设置红色进度条*/
|
||||||
#RedProgressBar {
|
#RedProgressBar {
|
||||||
text-align: center; /*进度值居中*/
|
text-align: center; /*进度值居中*/
|
||||||
}
|
}
|
||||||
#RedProgressBar::chunk {
|
#RedProgressBar::chunk {
|
||||||
background-color: #F44336;
|
background-color: #F44336;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#GreenProgressBar {
|
#GreenProgressBar {
|
||||||
min-height: 12px;
|
min-height: 12px;
|
||||||
max-height: 12px;
|
max-height: 12px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
#GreenProgressBar::chunk {
|
#GreenProgressBar::chunk {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background-color: #009688;
|
background-color: #009688;
|
||||||
}
|
}
|
||||||
|
|
||||||
#BlueProgressBar {
|
#BlueProgressBar {
|
||||||
border: 2px solid #2196F3;/*边框以及边框颜色*/
|
border: 2px solid #2196F3;/*边框以及边框颜色*/
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background-color: #E0E0E0;
|
background-color: #E0E0E0;
|
||||||
}
|
}
|
||||||
#BlueProgressBar::chunk {
|
#BlueProgressBar::chunk {
|
||||||
background-color: #2196F3;
|
background-color: #2196F3;
|
||||||
width: 10px; /*区块宽度*/
|
width: 10px; /*区块宽度*/
|
||||||
margin: 0.5px;
|
margin: 0.5px;
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
class ProgressBar(QProgressBar):
|
class ProgressBar(QProgressBar):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ProgressBar, self).__init__(*args, **kwargs)
|
super(ProgressBar, self).__init__(*args, **kwargs)
|
||||||
self.setValue(0)
|
self.setValue(0)
|
||||||
if self.minimum() != self.maximum():
|
if self.minimum() != self.maximum():
|
||||||
self.timer = QTimer(self, timeout=self.onTimeout)
|
self.timer = QTimer(self, timeout=self.onTimeout)
|
||||||
self.timer.start(randint(1, 3) * 1000)
|
self.timer.start(randint(1, 3) * 1000)
|
||||||
|
|
||||||
def onTimeout(self):
|
def onTimeout(self):
|
||||||
if self.value() >= 100:
|
if self.value() >= 100:
|
||||||
self.timer.stop()
|
self.timer.stop()
|
||||||
self.timer.deleteLater()
|
self.timer.deleteLater()
|
||||||
del self.timer
|
del self.timer
|
||||||
return
|
return
|
||||||
self.setValue(self.value() + 1)
|
self.setValue(self.value() + 1)
|
||||||
|
|
||||||
|
|
||||||
class Window(QWidget):
|
class Window(QWidget):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Window, self).__init__(*args, **kwargs)
|
super(Window, self).__init__(*args, **kwargs)
|
||||||
self.resize(800, 600)
|
self.resize(800, 600)
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.addWidget(
|
layout.addWidget(
|
||||||
ProgressBar(self, minimum=0, maximum=100, objectName="RedProgressBar"))
|
ProgressBar(self, minimum=0, maximum=100, objectName="RedProgressBar"))
|
||||||
layout.addWidget( # 繁忙状态
|
layout.addWidget( # 繁忙状态
|
||||||
ProgressBar(self, minimum=0, maximum=0, objectName="RedProgressBar"))
|
ProgressBar(self, minimum=0, maximum=0, objectName="RedProgressBar"))
|
||||||
|
|
||||||
layout.addWidget(
|
layout.addWidget(
|
||||||
ProgressBar(self, minimum=0, maximum=100, textVisible=False,
|
ProgressBar(self, minimum=0, maximum=100, textVisible=False,
|
||||||
objectName="GreenProgressBar"))
|
objectName="GreenProgressBar"))
|
||||||
layout.addWidget(
|
layout.addWidget(
|
||||||
ProgressBar(self, minimum=0, maximum=0, textVisible=False,
|
ProgressBar(self, minimum=0, maximum=0, textVisible=False,
|
||||||
objectName="GreenProgressBar"))
|
objectName="GreenProgressBar"))
|
||||||
|
|
||||||
layout.addWidget(
|
layout.addWidget(
|
||||||
ProgressBar(self, minimum=0, maximum=100, textVisible=False,
|
ProgressBar(self, minimum=0, maximum=100, textVisible=False,
|
||||||
objectName="BlueProgressBar"))
|
objectName="BlueProgressBar"))
|
||||||
layout.addWidget(
|
layout.addWidget(
|
||||||
ProgressBar(self, minimum=0, maximum=0, textVisible=False,
|
ProgressBar(self, minimum=0, maximum=0, textVisible=False,
|
||||||
objectName="BlueProgressBar"))
|
objectName="BlueProgressBar"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet(StyleSheet)
|
app.setStyleSheet(StyleSheet)
|
||||||
w = Window()
|
w = Window()
|
||||||
w.show()
|
w.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,10 +1,10 @@
|
||||||
# QProgressBar进度条 QSS 美化样式
|
# QProgressBar进度条 QSS 美化样式
|
||||||
|
|
||||||
主要改变背景颜色、高度、边框、块颜色、边框、圆角
|
主要改变背景颜色、高度、边框、块颜色、边框、圆角
|
||||||
|
|
||||||
详细美化都在代码里的QSS中注释了
|
详细美化都在代码里的QSS中注释了
|
||||||
|
|
||||||
效果图:
|
效果图:
|
||||||
|
|
||||||
### [ProgressBar.py](ProgressBar.py)
|
### [ProgressBar.py](ProgressBar.py)
|
||||||
![ProgressBar](ScreenShot/ProgressBar.gif)
|
![ProgressBar](ScreenShot/ProgressBar.gif)
|
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -1,113 +1,113 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月29日
|
Created on 2018年1月29日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: ButtonHover
|
@file: ButtonHover
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
import sys
|
import sys
|
||||||
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication
|
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
StyleSheet = '''
|
StyleSheet = '''
|
||||||
/*这里是通用设置,所有按钮都有效,不过后面的可以覆盖这个*/
|
/*这里是通用设置,所有按钮都有效,不过后面的可以覆盖这个*/
|
||||||
QPushButton {
|
QPushButton {
|
||||||
border: none; /*去掉边框*/
|
border: none; /*去掉边框*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QPushButton#xxx
|
QPushButton#xxx
|
||||||
或者
|
或者
|
||||||
#xx
|
#xx
|
||||||
都表示通过设置的objectName来指定
|
都表示通过设置的objectName来指定
|
||||||
*/
|
*/
|
||||||
QPushButton#RedButton {
|
QPushButton#RedButton {
|
||||||
background-color: #f44336; /*背景颜色*/
|
background-color: #f44336; /*背景颜色*/
|
||||||
}
|
}
|
||||||
#RedButton:hover {
|
#RedButton:hover {
|
||||||
background-color: #e57373; /*鼠标悬停时背景颜色*/
|
background-color: #e57373; /*鼠标悬停时背景颜色*/
|
||||||
}
|
}
|
||||||
/*注意pressed一定要放在hover的后面,否则没有效果*/
|
/*注意pressed一定要放在hover的后面,否则没有效果*/
|
||||||
#RedButton:pressed {
|
#RedButton:pressed {
|
||||||
background-color: #ffcdd2; /*鼠标按下不放时背景颜色*/
|
background-color: #ffcdd2; /*鼠标按下不放时背景颜色*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#GreenButton {
|
#GreenButton {
|
||||||
background-color: #4caf50;
|
background-color: #4caf50;
|
||||||
border-radius: 5px; /*圆角*/
|
border-radius: 5px; /*圆角*/
|
||||||
}
|
}
|
||||||
#GreenButton:hover {
|
#GreenButton:hover {
|
||||||
background-color: #81c784;
|
background-color: #81c784;
|
||||||
}
|
}
|
||||||
#GreenButton:pressed {
|
#GreenButton:pressed {
|
||||||
background-color: #c8e6c9;
|
background-color: #c8e6c9;
|
||||||
}
|
}
|
||||||
|
|
||||||
#BlueButton {
|
#BlueButton {
|
||||||
background-color: #2196f3;
|
background-color: #2196f3;
|
||||||
/*限制最小最大尺寸*/
|
/*限制最小最大尺寸*/
|
||||||
min-width: 96px;
|
min-width: 96px;
|
||||||
max-width: 96px;
|
max-width: 96px;
|
||||||
min-height: 96px;
|
min-height: 96px;
|
||||||
max-height: 96px;
|
max-height: 96px;
|
||||||
border-radius: 48px; /*圆形*/
|
border-radius: 48px; /*圆形*/
|
||||||
}
|
}
|
||||||
#BlueButton:hover {
|
#BlueButton:hover {
|
||||||
background-color: #64b5f6;
|
background-color: #64b5f6;
|
||||||
}
|
}
|
||||||
#BlueButton:pressed {
|
#BlueButton:pressed {
|
||||||
background-color: #bbdefb;
|
background-color: #bbdefb;
|
||||||
}
|
}
|
||||||
|
|
||||||
#OrangeButton {
|
#OrangeButton {
|
||||||
max-height: 48px;
|
max-height: 48px;
|
||||||
border-top-right-radius: 20px; /*右上角圆角*/
|
border-top-right-radius: 20px; /*右上角圆角*/
|
||||||
border-bottom-left-radius: 20px; /*左下角圆角*/
|
border-bottom-left-radius: 20px; /*左下角圆角*/
|
||||||
background-color: #ff9800;
|
background-color: #ff9800;
|
||||||
}
|
}
|
||||||
#OrangeButton:hover {
|
#OrangeButton:hover {
|
||||||
background-color: #ffb74d;
|
background-color: #ffb74d;
|
||||||
}
|
}
|
||||||
#OrangeButton:pressed {
|
#OrangeButton:pressed {
|
||||||
background-color: #ffe0b2;
|
background-color: #ffe0b2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*根据文字内容来区分按钮,同理还可以根据其它属性来区分*/
|
/*根据文字内容来区分按钮,同理还可以根据其它属性来区分*/
|
||||||
QPushButton[text="purple button"] {
|
QPushButton[text="purple button"] {
|
||||||
color: white; /*文字颜色*/
|
color: white; /*文字颜色*/
|
||||||
background-color: #9c27b0;
|
background-color: #9c27b0;
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
class Window(QWidget):
|
class Window(QWidget):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Window, self).__init__(*args, **kwargs)
|
super(Window, self).__init__(*args, **kwargs)
|
||||||
layout = QHBoxLayout(self)
|
layout = QHBoxLayout(self)
|
||||||
layout.addWidget(QPushButton("red button", self,
|
layout.addWidget(QPushButton("red button", self,
|
||||||
objectName="RedButton", minimumHeight=48))
|
objectName="RedButton", minimumHeight=48))
|
||||||
layout.addWidget(QPushButton("green button", self,
|
layout.addWidget(QPushButton("green button", self,
|
||||||
objectName="GreenButton", minimumHeight=48))
|
objectName="GreenButton", minimumHeight=48))
|
||||||
layout.addWidget(QPushButton("blue button", self,
|
layout.addWidget(QPushButton("blue button", self,
|
||||||
objectName="BlueButton", minimumHeight=48))
|
objectName="BlueButton", minimumHeight=48))
|
||||||
layout.addWidget(QPushButton("orange button", self,
|
layout.addWidget(QPushButton("orange button", self,
|
||||||
objectName="OrangeButton", minimumHeight=48))
|
objectName="OrangeButton", minimumHeight=48))
|
||||||
layout.addWidget(QPushButton("purple button", self,
|
layout.addWidget(QPushButton("purple button", self,
|
||||||
objectName="PurpleButton", minimumHeight=48))
|
objectName="PurpleButton", minimumHeight=48))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet(StyleSheet)
|
app.setStyleSheet(StyleSheet)
|
||||||
w = Window()
|
w = Window()
|
||||||
w.show()
|
w.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -1,90 +1,90 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年2月1日
|
Created on 2018年2月1日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: PushButtonFont
|
@file: PushButtonFont
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QPropertyAnimation, Qt, QRectF
|
from PyQt5.QtCore import QPropertyAnimation, Qt, QRectF
|
||||||
from PyQt5.QtGui import QFontDatabase
|
from PyQt5.QtGui import QFontDatabase
|
||||||
from PyQt5.QtWidgets import QPushButton, QApplication, QStyleOptionButton,\
|
from PyQt5.QtWidgets import QPushButton, QApplication, QStyleOptionButton,\
|
||||||
QStylePainter, QStyle
|
QStylePainter, QStyle
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
|
|
||||||
class PushButtonFont(QPushButton):
|
class PushButtonFont(QPushButton):
|
||||||
|
|
||||||
LoadingText = "\uf110"
|
LoadingText = "\uf110"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PushButtonFont, self).__init__(*args, **kwargs)
|
super(PushButtonFont, self).__init__(*args, **kwargs)
|
||||||
self.fontSize = self.font().pointSize() * 2
|
self.fontSize = self.font().pointSize() * 2
|
||||||
self._rotateAnimationStarted = False
|
self._rotateAnimationStarted = False
|
||||||
self._rotateAnimation = QPropertyAnimation(self)
|
self._rotateAnimation = QPropertyAnimation(self)
|
||||||
self._rotateAnimation.setTargetObject(self)
|
self._rotateAnimation.setTargetObject(self)
|
||||||
self._rotateAnimation.setStartValue(1)
|
self._rotateAnimation.setStartValue(1)
|
||||||
self._rotateAnimation.setEndValue(12)
|
self._rotateAnimation.setEndValue(12)
|
||||||
self._rotateAnimation.setDuration(1000)
|
self._rotateAnimation.setDuration(1000)
|
||||||
self._rotateAnimation.setLoopCount(-1) # 无限循环
|
self._rotateAnimation.setLoopCount(-1) # 无限循环
|
||||||
self._rotateAnimation.valueChanged.connect(self.update)
|
self._rotateAnimation.valueChanged.connect(self.update)
|
||||||
self.clicked.connect(self._onClick)
|
self.clicked.connect(self._onClick)
|
||||||
|
|
||||||
def paintEvent(self, _):
|
def paintEvent(self, _):
|
||||||
option = QStyleOptionButton()
|
option = QStyleOptionButton()
|
||||||
self.initStyleOption(option)
|
self.initStyleOption(option)
|
||||||
painter = QStylePainter(self)
|
painter = QStylePainter(self)
|
||||||
if self._rotateAnimationStarted:
|
if self._rotateAnimationStarted:
|
||||||
option.text = ""
|
option.text = ""
|
||||||
painter.drawControl(QStyle.CE_PushButton, option)
|
painter.drawControl(QStyle.CE_PushButton, option)
|
||||||
if not self._rotateAnimationStarted:
|
if not self._rotateAnimationStarted:
|
||||||
return
|
return
|
||||||
painter.save()
|
painter.save()
|
||||||
font = self.font()
|
font = self.font()
|
||||||
font.setPointSize(self.fontSize)
|
font.setPointSize(self.fontSize)
|
||||||
font.setFamily("FontAwesome")
|
font.setFamily("FontAwesome")
|
||||||
painter.setFont(font)
|
painter.setFont(font)
|
||||||
# 变换坐标为正中间
|
# 变换坐标为正中间
|
||||||
painter.translate(self.rect().center())
|
painter.translate(self.rect().center())
|
||||||
# 旋转90度
|
# 旋转90度
|
||||||
painter.rotate(self._rotateAnimation.currentValue() * 30)
|
painter.rotate(self._rotateAnimation.currentValue() * 30)
|
||||||
fm = self.fontMetrics()
|
fm = self.fontMetrics()
|
||||||
# 在变换坐标后的正中间画文字
|
# 在变换坐标后的正中间画文字
|
||||||
w = fm.width(self.LoadingText)
|
w = fm.width(self.LoadingText)
|
||||||
h = fm.height()
|
h = fm.height()
|
||||||
painter.drawText(
|
painter.drawText(
|
||||||
QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter,
|
QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter,
|
||||||
self.LoadingText)
|
self.LoadingText)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
|
||||||
def _onClick(self):
|
def _onClick(self):
|
||||||
if self._rotateAnimationStarted:
|
if self._rotateAnimationStarted:
|
||||||
self._rotateAnimationStarted = False
|
self._rotateAnimationStarted = False
|
||||||
self._rotateAnimation.stop()
|
self._rotateAnimation.stop()
|
||||||
return
|
return
|
||||||
self._rotateAnimationStarted = True
|
self._rotateAnimationStarted = True
|
||||||
self._rotateAnimation.start()
|
self._rotateAnimation.start()
|
||||||
|
|
||||||
def update(self, _=None):
|
def update(self, _=None):
|
||||||
super(PushButtonFont, self).update()
|
super(PushButtonFont, self).update()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
# 加载字体到字体库中
|
# 加载字体到字体库中
|
||||||
QFontDatabase.addApplicationFont(
|
QFontDatabase.addApplicationFont(
|
||||||
"Fonts/FontAwesome/fontawesome-webfont.ttf")
|
"Fonts/FontAwesome/fontawesome-webfont.ttf")
|
||||||
w = PushButtonFont("点击加载")
|
w = PushButtonFont("点击加载")
|
||||||
w.show()
|
w.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,116 +1,116 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年2月1日
|
Created on 2018年2月1日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: PushButtonLine
|
@file: PushButtonLine
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
from random import randint
|
from random import randint
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer, QThread, pyqtSignal
|
from PyQt5.QtCore import QTimer, QThread, pyqtSignal
|
||||||
from PyQt5.QtGui import QPainter, QColor, QPen
|
from PyQt5.QtGui import QPainter, QColor, QPen
|
||||||
from PyQt5.QtWidgets import QPushButton, QApplication, QWidget, QVBoxLayout
|
from PyQt5.QtWidgets import QPushButton, QApplication, QWidget, QVBoxLayout
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
StyleSheet = '''
|
StyleSheet = '''
|
||||||
PushButtonLine {
|
PushButtonLine {
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
min-height: 48px;
|
min-height: 48px;
|
||||||
background-color: #90caf9;
|
background-color: #90caf9;
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
class LoadingThread(QThread):
|
class LoadingThread(QThread):
|
||||||
|
|
||||||
valueChanged = pyqtSignal(float) # 当前值/最大值
|
valueChanged = pyqtSignal(float) # 当前值/最大值
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(LoadingThread, self).__init__(*args, **kwargs)
|
super(LoadingThread, self).__init__(*args, **kwargs)
|
||||||
self.totalValue = randint(100, 200) # 模拟最大
|
self.totalValue = randint(100, 200) # 模拟最大
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
for i in range(self.totalValue + 1):
|
for i in range(self.totalValue + 1):
|
||||||
self.valueChanged.emit(i / self.totalValue)
|
self.valueChanged.emit(i / self.totalValue)
|
||||||
QThread.msleep(randint(300, 600))
|
QThread.msleep(randint(300, 600))
|
||||||
|
|
||||||
|
|
||||||
class PushButtonLine(QPushButton):
|
class PushButtonLine(QPushButton):
|
||||||
|
|
||||||
lineColor = QColor(0, 150, 136)
|
lineColor = QColor(0, 150, 136)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._waitText = kwargs.pop("waitText", "等待中")
|
self._waitText = kwargs.pop("waitText", "等待中")
|
||||||
super(PushButtonLine, self).__init__(*args, **kwargs)
|
super(PushButtonLine, self).__init__(*args, **kwargs)
|
||||||
self._text = self.text()
|
self._text = self.text()
|
||||||
self._percent = 0
|
self._percent = 0
|
||||||
self._timer = QTimer(self, timeout=self.update)
|
self._timer = QTimer(self, timeout=self.update)
|
||||||
self.clicked.connect(self.start)
|
self.clicked.connect(self.start)
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
super(PushButtonLine, self).paintEvent(event)
|
super(PushButtonLine, self).paintEvent(event)
|
||||||
if not self._timer.isActive():
|
if not self._timer.isActive():
|
||||||
return
|
return
|
||||||
# 画进度
|
# 画进度
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
pen = QPen(self.lineColor)
|
pen = QPen(self.lineColor)
|
||||||
pen.setWidth(4)
|
pen.setWidth(4)
|
||||||
painter.setPen(pen)
|
painter.setPen(pen)
|
||||||
painter.drawLine(0, self.height(), self.width()
|
painter.drawLine(0, self.height(), self.width()
|
||||||
* self._percent, self.height())
|
* self._percent, self.height())
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if hasattr(self, "loadingThread"):
|
if hasattr(self, "loadingThread"):
|
||||||
return self.stop()
|
return self.stop()
|
||||||
self.loadingThread = LoadingThread(self)
|
self.loadingThread = LoadingThread(self)
|
||||||
self.loadingThread.valueChanged.connect(self.setPercent)
|
self.loadingThread.valueChanged.connect(self.setPercent)
|
||||||
self._timer.start(200) # 200ms
|
self._timer.start(200) # 200ms
|
||||||
self.loadingThread.start()
|
self.loadingThread.start()
|
||||||
self.setText(self._waitText)
|
self.setText(self._waitText)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.loadingThread.valueChanged.disconnect(self.setPercent)
|
self.loadingThread.valueChanged.disconnect(self.setPercent)
|
||||||
self.loadingThread.terminate()
|
self.loadingThread.terminate()
|
||||||
self.loadingThread.deleteLater()
|
self.loadingThread.deleteLater()
|
||||||
del self.loadingThread
|
del self.loadingThread
|
||||||
self._percent = 0
|
self._percent = 0
|
||||||
self._timer.stop()
|
self._timer.stop()
|
||||||
self.setText(self._text)
|
self.setText(self._text)
|
||||||
|
|
||||||
def setPercent(self, v):
|
def setPercent(self, v):
|
||||||
self._percent = v
|
self._percent = v
|
||||||
if v == 1:
|
if v == 1:
|
||||||
self.stop()
|
self.stop()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def setLineColor(self, color):
|
def setLineColor(self, color):
|
||||||
self.lineColor = QColor(color)
|
self.lineColor = QColor(color)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class Window(QWidget):
|
class Window(QWidget):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Window, self).__init__(*args, **kwargs)
|
super(Window, self).__init__(*args, **kwargs)
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.addWidget(PushButtonLine("点击加载"))
|
layout.addWidget(PushButtonLine("点击加载"))
|
||||||
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ef5350"))
|
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ef5350"))
|
||||||
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ffc107"))
|
layout.addWidget(PushButtonLine("点击加载").setLineColor("#ffc107"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setStyleSheet(StyleSheet)
|
app.setStyleSheet(StyleSheet)
|
||||||
w = Window()
|
w = Window()
|
||||||
w.show()
|
w.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,20 +1,20 @@
|
||||||
# QScrollBar滚动条样式美化
|
# QScrollBar滚动条样式美化
|
||||||
|
|
||||||
### 滚动条分两个方向
|
### 滚动条分两个方向
|
||||||
- horizontal 横向
|
- horizontal 横向
|
||||||
- vertical 纵向
|
- vertical 纵向
|
||||||
|
|
||||||
### 简单说明
|
### 简单说明
|
||||||
- 横向或纵向滚动条整体,也就是(horizontal、vertical)
|
- 横向或纵向滚动条整体,也就是(horizontal、vertical)
|
||||||
- 滚动条上面的小滑块(handle)
|
- 滚动条上面的小滑块(handle)
|
||||||
- 纵向上部、横向左侧区域(sub-page)
|
- 纵向上部、横向左侧区域(sub-page)
|
||||||
- 纵向下部、横向右侧区域(add-page)
|
- 纵向下部、横向右侧区域(add-page)
|
||||||
- 纵向上部、横向左侧三角形区域(sub-line)
|
- 纵向上部、横向左侧三角形区域(sub-line)
|
||||||
- 纵向下部、横向右侧三角形区域(add-line)
|
- 纵向下部、横向右侧三角形区域(add-line)
|
||||||
- 纵向上部、横向左侧三角形(up-arrow、left-arrow)
|
- 纵向上部、横向左侧三角形(up-arrow、left-arrow)
|
||||||
- 纵向下部、横向右侧三角形(down-arrow、right-arrow)
|
- 纵向下部、横向右侧三角形(down-arrow、right-arrow)
|
||||||
|
|
||||||
截图
|
截图
|
||||||
|
|
||||||
![1](ScreenShot/1.jpg)
|
![1](ScreenShot/1.jpg)
|
||||||
![2](ScreenShot/2.jpg)
|
![2](ScreenShot/2.jpg)
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1,45 +1,45 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 2018年1月20日
|
Created on 2018年1月20日
|
||||||
@author: Irony."[讽刺]
|
@author: Irony."[讽刺]
|
||||||
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: ScrollBar
|
@file: ScrollBar
|
||||||
@description:
|
@description:
|
||||||
'''
|
'''
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QTextEdit, QApplication
|
from PyQt5.QtWidgets import QTextEdit, QApplication
|
||||||
import chardet
|
import chardet
|
||||||
|
|
||||||
|
|
||||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||||
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
|
||||||
__Version__ = "Version 1.0"
|
__Version__ = "Version 1.0"
|
||||||
|
|
||||||
|
|
||||||
class Window(QTextEdit):
|
class Window(QTextEdit):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(Window, self).__init__(parent)
|
super(Window, self).__init__(parent)
|
||||||
# 设置横向纵向滚动条总是显示
|
# 设置横向纵向滚动条总是显示
|
||||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
||||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
||||||
with open("ScrollBar.qss", "rb") as fp:
|
with open("ScrollBar.qss", "rb") as fp:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
encoding = chardet.detect(content) or {}
|
encoding = chardet.detect(content) or {}
|
||||||
content = content.decode(encoding.get("encoding") or "utf-8")
|
content = content.decode(encoding.get("encoding") or "utf-8")
|
||||||
self.setText(content)
|
self.setText(content)
|
||||||
# 设置样式
|
# 设置样式
|
||||||
self.setStyleSheet(content)
|
self.setStyleSheet(content)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setApplicationName("滚动条样式")
|
app.setApplicationName("滚动条样式")
|
||||||
app.setApplicationDisplayName("滚动条样式")
|
app.setApplicationDisplayName("滚动条样式")
|
||||||
window = Window()
|
window = Window()
|
||||||
window.show()
|
window.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
|
@ -1,142 +1,142 @@
|
||||||
/*QScrollBar Style*/
|
/*QScrollBar Style*/
|
||||||
|
|
||||||
/*纵向滚动条*/
|
/*纵向滚动条*/
|
||||||
QScrollBar:vertical {
|
QScrollBar:vertical {
|
||||||
background: transparent; /*背景透明*/
|
background: transparent; /*背景透明*/
|
||||||
width: 10px; /*宽度*/
|
width: 10px; /*宽度*/
|
||||||
margin: 0px 0px 0px 0px; /**/
|
margin: 0px 0px 0px 0px; /**/
|
||||||
padding-top: 12px; /*距离上面12px*/
|
padding-top: 12px; /*距离上面12px*/
|
||||||
padding-bottom: 12px; /*距离底部12px*/
|
padding-bottom: 12px; /*距离底部12px*/
|
||||||
}
|
}
|
||||||
/*横向滚动条*/
|
/*横向滚动条*/
|
||||||
QScrollBar:horizontal {
|
QScrollBar:horizontal {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
height: 10px; /*高度*/
|
height: 10px; /*高度*/
|
||||||
margin: 0px 0px 0px 0px;
|
margin: 0px 0px 0px 0px;
|
||||||
padding-left: 12px; /*距离左边12px*/
|
padding-left: 12px; /*距离左边12px*/
|
||||||
padding-right: 12px; /*距离右边12px*/
|
padding-right: 12px; /*距离右边12px*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*当鼠标放到纵向或者横向滚动条上面时*/
|
/*当鼠标放到纵向或者横向滚动条上面时*/
|
||||||
QScrollBar:vertical:hover,QScrollBar:horizontal:hover {
|
QScrollBar:vertical:hover,QScrollBar:horizontal:hover {
|
||||||
background: rgba(0, 0, 0, 30); /*修改背景透明度 30*/
|
background: rgba(0, 0, 0, 30); /*修改背景透明度 30*/
|
||||||
border-radius: 5px; /*圆角*/
|
border-radius: 5px; /*圆角*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*纵向滚动条上面的滑块*/
|
/*纵向滚动条上面的滑块*/
|
||||||
QScrollBar::handle:vertical {
|
QScrollBar::handle:vertical {
|
||||||
background: rgba(0, 0, 0, 50);
|
background: rgba(0, 0, 0, 50);
|
||||||
width: 10px;
|
width: 10px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
/*横向滚动条上面的滑块*/
|
/*横向滚动条上面的滑块*/
|
||||||
QScrollBar::handle:horizontal {
|
QScrollBar::handle:horizontal {
|
||||||
background: rgba(0, 0, 0, 50);
|
background: rgba(0, 0, 0, 50);
|
||||||
height: 10px;
|
height: 10px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*当鼠标放到滚动条滑块上面时改变透明度实现颜色的深浅变化*/
|
/*当鼠标放到滚动条滑块上面时改变透明度实现颜色的深浅变化*/
|
||||||
QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover {
|
QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover {
|
||||||
background: rgba(0, 0, 0, 100);
|
background: rgba(0, 0, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*纵向滚动条下部分块*/
|
/*纵向滚动条下部分块*/
|
||||||
QScrollBar::add-page:vertical {
|
QScrollBar::add-page:vertical {
|
||||||
width: 10px;
|
width: 10px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
/*横向滚动条后面部分块*/
|
/*横向滚动条后面部分块*/
|
||||||
QScrollBar::add-page:horizontal {
|
QScrollBar::add-page:horizontal {
|
||||||
height: 10px;
|
height: 10px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
/*纵向滚动条上面部分块*/
|
/*纵向滚动条上面部分块*/
|
||||||
QScrollBar::sub-page:vertical {
|
QScrollBar::sub-page:vertical {
|
||||||
width: 10px;
|
width: 10px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
/*横向滚动条左部分块*/
|
/*横向滚动条左部分块*/
|
||||||
QScrollBar::sub-page:horizontal {
|
QScrollBar::sub-page:horizontal {
|
||||||
height: 10px;
|
height: 10px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
/*纵向滚动条顶部三角形位置*/
|
/*纵向滚动条顶部三角形位置*/
|
||||||
QScrollBar::sub-line:vertical {
|
QScrollBar::sub-line:vertical {
|
||||||
height: 12px;
|
height: 12px;
|
||||||
width: 10px;
|
width: 10px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
subcontrol-position: top;
|
subcontrol-position: top;
|
||||||
}
|
}
|
||||||
/*横向滚动条左侧三角形位置*/
|
/*横向滚动条左侧三角形位置*/
|
||||||
QScrollBar::sub-line:horizontal {
|
QScrollBar::sub-line:horizontal {
|
||||||
height: 10px;
|
height: 10px;
|
||||||
width: 12px;
|
width: 12px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
subcontrol-position: left;
|
subcontrol-position: left;
|
||||||
}
|
}
|
||||||
/*纵向滚动条向上的三角形小图标*/
|
/*纵向滚动条向上的三角形小图标*/
|
||||||
QScrollBar::up-arrow:vertical {
|
QScrollBar::up-arrow:vertical {
|
||||||
image: url(scrollbar/scrollbar_arrowup_normal.png);
|
image: url(scrollbar/scrollbar_arrowup_normal.png);
|
||||||
}
|
}
|
||||||
/*横向滚动条左边的三角形小图标*/
|
/*横向滚动条左边的三角形小图标*/
|
||||||
QScrollBar::left-arrow:horizontal {
|
QScrollBar::left-arrow:horizontal {
|
||||||
image: url(scrollbar/scrollbar_arrowleft_normal.png);
|
image: url(scrollbar/scrollbar_arrowleft_normal.png);
|
||||||
}
|
}
|
||||||
/*纵向滚动条向上的三角形小图标 鼠标悬停*/
|
/*纵向滚动条向上的三角形小图标 鼠标悬停*/
|
||||||
QScrollBar::up-arrow:vertical:hover {
|
QScrollBar::up-arrow:vertical:hover {
|
||||||
image: url(scrollbar/scrollbar_arrowup_down.png);
|
image: url(scrollbar/scrollbar_arrowup_down.png);
|
||||||
}
|
}
|
||||||
/*横向滚动条左边的三角形小图标 鼠标悬停*/
|
/*横向滚动条左边的三角形小图标 鼠标悬停*/
|
||||||
QScrollBar::left-arrow:horizontal:hover {
|
QScrollBar::left-arrow:horizontal:hover {
|
||||||
image: url(scrollbar/scrollbar_arrowleft_down.png);
|
image: url(scrollbar/scrollbar_arrowleft_down.png);
|
||||||
}
|
}
|
||||||
/*纵向滚动条向上的三角形小图标 鼠标按下*/
|
/*纵向滚动条向上的三角形小图标 鼠标按下*/
|
||||||
QScrollBar::up-arrow:vertical:pressed {
|
QScrollBar::up-arrow:vertical:pressed {
|
||||||
image: url(scrollbar/scrollbar_arrowup_highlight.png);
|
image: url(scrollbar/scrollbar_arrowup_highlight.png);
|
||||||
}
|
}
|
||||||
/*横向滚动条左边的三角形小图标 鼠标按下*/
|
/*横向滚动条左边的三角形小图标 鼠标按下*/
|
||||||
QScrollBar::left-arrow:horizontal:pressed {
|
QScrollBar::left-arrow:horizontal:pressed {
|
||||||
image: url(scrollbar/scrollbar_arrowleft_highlight.png);
|
image: url(scrollbar/scrollbar_arrowleft_highlight.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*纵向滚动条下面三角形部分*/
|
/*纵向滚动条下面三角形部分*/
|
||||||
QScrollBar::add-line:vertical {
|
QScrollBar::add-line:vertical {
|
||||||
height: 12px;
|
height: 12px;
|
||||||
width: 10px;
|
width: 10px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
subcontrol-position: bottom;
|
subcontrol-position: bottom;
|
||||||
}
|
}
|
||||||
/*横向滚动条右边的三角形部分*/
|
/*横向滚动条右边的三角形部分*/
|
||||||
QScrollBar::add-line:horizontal {
|
QScrollBar::add-line:horizontal {
|
||||||
height: 10px;
|
height: 10px;
|
||||||
width: 12px;
|
width: 12px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
subcontrol-position: right;
|
subcontrol-position: right;
|
||||||
}
|
}
|
||||||
/*纵向滚动条下面三角形图标*/
|
/*纵向滚动条下面三角形图标*/
|
||||||
QScrollBar::down-arrow:vertical {
|
QScrollBar::down-arrow:vertical {
|
||||||
image: url(scrollbar/scrollbar_arrowdown_normal.png);
|
image: url(scrollbar/scrollbar_arrowdown_normal.png);
|
||||||
}
|
}
|
||||||
/*横向滚动条右侧三角形图标*/
|
/*横向滚动条右侧三角形图标*/
|
||||||
QScrollBar::right-arrow:horizontal {
|
QScrollBar::right-arrow:horizontal {
|
||||||
image: url(scrollbar/scrollbar_arrowright_normal.png);
|
image: url(scrollbar/scrollbar_arrowright_normal.png);
|
||||||
}
|
}
|
||||||
/*纵向滚动条下面三角形图标 鼠标悬停*/
|
/*纵向滚动条下面三角形图标 鼠标悬停*/
|
||||||
QScrollBar::down-arrow:vertical:hover {
|
QScrollBar::down-arrow:vertical:hover {
|
||||||
image: url(scrollbar/scrollbar_arrowdown_down.png);
|
image: url(scrollbar/scrollbar_arrowdown_down.png);
|
||||||
}
|
}
|
||||||
/*横向滚动条右侧三角形图标 鼠标悬停*/
|
/*横向滚动条右侧三角形图标 鼠标悬停*/
|
||||||
QScrollBar::right-arrow:horizontal:hover {
|
QScrollBar::right-arrow:horizontal:hover {
|
||||||
image: url(scrollbar/scrollbar_arrowright_down.png);
|
image: url(scrollbar/scrollbar_arrowright_down.png);
|
||||||
}
|
}
|
||||||
/*纵向滚动条下面三角形图标 鼠标按下*/
|
/*纵向滚动条下面三角形图标 鼠标按下*/
|
||||||
QScrollBar::down-arrow:vertical:pressed {
|
QScrollBar::down-arrow:vertical:pressed {
|
||||||
image: url(scrollbar/scrollbar_arrowdown_highlight.png);
|
image: url(scrollbar/scrollbar_arrowdown_highlight.png);
|
||||||
}
|
}
|
||||||
/*横向滚动条右侧三角形图标 鼠标按下*/
|
/*横向滚动条右侧三角形图标 鼠标按下*/
|
||||||
QScrollBar::right-arrow:horizontal:pressed {
|
QScrollBar::right-arrow:horizontal:pressed {
|
||||||
image: url(scrollbar/scrollbar_arrowright_highlight.png);
|
image: url(scrollbar/scrollbar_arrowright_highlight.png);
|
||||||
}
|
}
|
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
31
美化/README.md
Normal 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)
|
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 821 KiB After Width: | Height: | Size: 821 KiB |