diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 3f7ba34..5784359 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -65,37 +65,13 @@ encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/\u4EFF encoding//\u591A\u9875\u9762/QStackedWidget/\u5DE6\u4FA7\u9009\u9879\u5361/\u5DE6\u4FA7\u9009\u9879\u5361.py=utf-8 encoding//\u6811\u7ED3\u6784/QTreeWidget/Json\u751F\u6210QTreeWidget/Json\u751F\u6210\u6811\u5F62\u7ED3\u6784.py=utf-8 encoding//\u6D4F\u89C8\u5668/QWebView/\u68A6\u5E7B\u6811/DreamTree.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QFileSystemModel\u56FE\u6807/FileSystemModel.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QLabel\u5706\u5F62\u5934\u50CF/CircleLabel.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/critical.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/information.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/question.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/warning.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/critical.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/information.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/question.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E8C/warning.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QPushButton\u8FDB\u5EA6\u52A8\u753B/PushButtonFont.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QPushButton\u8FDB\u5EA6\u52A8\u753B/PushButtonLine.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QSS\u7F8E\u5316\u4F8B\u5B50/QProgressBar\u8FDB\u5EA6\u6761\u6837\u5F0F/ProgressBar.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QSS\u7F8E\u5316\u4F8B\u5B50/QPushButton\u6309\u94AE/ButtonHover.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QScrollBar\u6EDA\u52A8\u6761\u6837\u5F0F/ScrollBar.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QSlider\u7F8E\u5316/PaintQSlider.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/QSlider\u7F8E\u5316/QssQSlider.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/CircleProgressBar.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/MetroCircleProgress.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/MetroLineProgress.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u5404\u7C7B\u8FDB\u5EA6\u6761/PercentProgressBar.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u6C34\u6CE2\u7EB9\u8FDB\u5EA6\u6761/ProgressBar.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u6C34\u6CE2\u7EB9\u8FDB\u5EA6\u6761/TestWidget.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u8FB9\u6846\u52A8\u753B\u9634\u5F71/AnimationShadowEffect.py=utf-8 -encoding//\u754C\u9762\u7F8E\u5316/\u8FB9\u6846\u52A8\u753B\u9634\u5F71/Test.py=utf-8 encoding//\u7A97\u53E3/\u5206\u5272\u7A97\u53E3\u7684\u5206\u5272\u6761\u91CD\u5199.py=utf-8 encoding//\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3/FramelessWindow.py=utf-8 encoding//\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3/win\u65E0\u8FB9\u6846\u8C03\u6574\u5927\u5C0F.py=utf-8 encoding//\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3/\u65E0\u8FB9\u6846\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7A97\u53E3.py=utf-8 encoding//\u7A97\u53E3/\u6D88\u606F\u5BF9\u8BDD\u6846\u5012\u8BA1\u65F6\u5173\u95ED.py=utf-8 encoding//\u7A97\u53E3/\u7A97\u53E3\u91CD\u542F.py=utf-8 +encoding//\u7F8E\u5316/QLabel/\u5706\u5F62\u56FE\u7247.py=utf-8 encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/CustomPaintWidget.py=utf-8 encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/CustomWidget.py=utf-8 encoding//\u7F8E\u5316/\u81EA\u5B9A\u4E49QWidget\u7684QSS\u6837\u5F0F/test.py=utf-8 diff --git a/界面美化/QLabel圆形头像/README.md b/界面美化/QLabel圆形头像/README.md deleted file mode 100644 index e24ec51..0000000 --- a/界面美化/QLabel圆形头像/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# QLabel圆形头像 - -一种比较好的方法制作圆形头像 - -### 简单说明 -该方法使用QPainter的 setClipPath 方法结合QPainterPath对图片进行裁剪。 - -截图 - -![1](ScreenShot/1.png) \ No newline at end of file diff --git a/界面美化/QPushButton进度动画/README.md b/界面美化/QPushButton进度动画/README.md deleted file mode 100644 index 29bf4b6..0000000 --- a/界面美化/QPushButton进度动画/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# QPushButton 加载动画 - -### 简单说明 - - 1.第一种是利用字体,使用FontAwesome字体来显示一个圆形进度条,然后利用旋转动画 - - 2.第二种是在按钮下方画一条线,根据百分值绘制 - -截图 - -![1](ScreenShot/1.gif) -![1](ScreenShot/2.gif) \ No newline at end of file diff --git a/界面美化/QSS美化例子/QPushButton按钮/README.md b/界面美化/QSS美化例子/QPushButton按钮/README.md deleted file mode 100644 index 1dfd0da..0000000 --- a/界面美化/QSS美化例子/QPushButton按钮/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# QPushButton 按钮 QSS 美化样式 - -主要改变背景颜色、鼠标按下颜色、鼠标悬停颜色、圆角、圆形、文字颜色 - -效果图: - -### [ButtonHover.py](ButtonHover.py) -![ButtonHover](ScreenShot/ButtonHover.gif) \ No newline at end of file diff --git a/界面美化/QSS美化例子/README.md b/界面美化/QSS美化例子/README.md deleted file mode 100644 index 7dc4a2e..0000000 --- a/界面美化/QSS美化例子/README.md +++ /dev/null @@ -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) \ No newline at end of file diff --git a/界面美化/README.md b/界面美化/README.md deleted file mode 100644 index 1b61a31..0000000 --- a/界面美化/README.md +++ /dev/null @@ -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.各类进度条](各类进度条/) \ No newline at end of file diff --git a/界面美化/QSS美化例子/QCalendarWidget日历/CalendarWidget.py b/美化/QCalendarWidget/CalendarWidget.py similarity index 96% rename from 界面美化/QSS美化例子/QCalendarWidget日历/CalendarWidget.py rename to 美化/QCalendarWidget/CalendarWidget.py index ac633da..0fe3e84 100644 --- a/界面美化/QSS美化例子/QCalendarWidget日历/CalendarWidget.py +++ b/美化/QCalendarWidget/CalendarWidget.py @@ -1,117 +1,117 @@ -''' -Created on 2018年1月30日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: CalendarWidget -@description: 日历 -''' -import sys - -from PyQt5.QtWidgets import QApplication, QCalendarWidget - - -StyleSheet = ''' -/*顶部导航区域*/ -#qt_calendar_navigationbar { - background-color: rgb(0, 188, 212); - min-height: 100px; -} - - -/*上一个月按钮和下一个月按钮(从源码里找到的objectName)*/ -#qt_calendar_prevmonth, #qt_calendar_nextmonth { - border: none; /*去掉边框*/ - margin-top: 64px; - color: white; - min-width: 36px; - max-width: 36px; - min-height: 36px; - max-height: 36px; - border-radius: 18px; /*看来近似椭圆*/ - font-weight: bold; /*字体加粗*/ - qproperty-icon: none; /*去掉默认的方向键图片,当然也可以自定义*/ - background-color: transparent;/*背景颜色透明*/ -} -#qt_calendar_prevmonth { - qproperty-text: "<"; /*修改按钮的文字*/ -} -#qt_calendar_nextmonth { - qproperty-text: ">"; -} -#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover { - background-color: rgba(225, 225, 225, 100); -} -#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed { - background-color: rgba(235, 235, 235, 100); -} - - -/*年,月控件*/ -#qt_calendar_yearbutton, #qt_calendar_monthbutton { - color: white; - margin: 18px; - min-width: 60px; - border-radius: 30px; -} -#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover { - background-color: rgba(225, 225, 225, 100); -} -#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed { - background-color: rgba(235, 235, 235, 100); -} - - -/*年份输入框*/ -#qt_calendar_yearedit { - min-width: 50px; - color: white; - background: transparent;/*让输入框背景透明*/ -} -#qt_calendar_yearedit::up-button { /*往上的按钮*/ - width: 20px; - subcontrol-position: right;/*移动到右边*/ -} -#qt_calendar_yearedit::down-button { /*往下的按钮*/ - width: 20px; - subcontrol-position: left; /*移动到左边去*/ -} - - -/*月份选择菜单*/ -CalendarWidget QToolButton QMenu { - background-color: white; -} -CalendarWidget QToolButton QMenu::item { - padding: 10px; -} -CalendarWidget QToolButton QMenu::item:selected:enabled { - background-color: rgb(230, 230, 230); -} -CalendarWidget QToolButton::menu-indicator { - /*image: none;去掉月份选择下面的小箭头*/ - subcontrol-position: right center;/*右边居中*/ -} - - -/*下方的日历表格*/ -#qt_calendar_calendarview { - outline: 0px;/*去掉选中后的虚线框*/ - selection-background-color: rgb(0, 188, 212); /*选中背景颜色*/ -} -''' - - -class CalendarWidget(QCalendarWidget): - - def __init__(self, *args, **kwargs): - super(CalendarWidget, self).__init__(*args, **kwargs) - # 隐藏左边的序号 - self.setVerticalHeaderFormat(self.NoVerticalHeader) - -if __name__ == "__main__": - app = QApplication(sys.argv) - app.setStyleSheet(StyleSheet) - w = CalendarWidget() - w.show() - sys.exit(app.exec_()) +''' +Created on 2018年1月30日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: CalendarWidget +@description: 日历 +''' +import sys + +from PyQt5.QtWidgets import QApplication, QCalendarWidget + + +StyleSheet = ''' +/*顶部导航区域*/ +#qt_calendar_navigationbar { + background-color: rgb(0, 188, 212); + min-height: 100px; +} + + +/*上一个月按钮和下一个月按钮(从源码里找到的objectName)*/ +#qt_calendar_prevmonth, #qt_calendar_nextmonth { + border: none; /*去掉边框*/ + margin-top: 64px; + color: white; + min-width: 36px; + max-width: 36px; + min-height: 36px; + max-height: 36px; + border-radius: 18px; /*看来近似椭圆*/ + font-weight: bold; /*字体加粗*/ + qproperty-icon: none; /*去掉默认的方向键图片,当然也可以自定义*/ + background-color: transparent;/*背景颜色透明*/ +} +#qt_calendar_prevmonth { + qproperty-text: "<"; /*修改按钮的文字*/ +} +#qt_calendar_nextmonth { + qproperty-text: ">"; +} +#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover { + background-color: rgba(225, 225, 225, 100); +} +#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed { + background-color: rgba(235, 235, 235, 100); +} + + +/*年,月控件*/ +#qt_calendar_yearbutton, #qt_calendar_monthbutton { + color: white; + margin: 18px; + min-width: 60px; + border-radius: 30px; +} +#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover { + background-color: rgba(225, 225, 225, 100); +} +#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed { + background-color: rgba(235, 235, 235, 100); +} + + +/*年份输入框*/ +#qt_calendar_yearedit { + min-width: 50px; + color: white; + background: transparent;/*让输入框背景透明*/ +} +#qt_calendar_yearedit::up-button { /*往上的按钮*/ + width: 20px; + subcontrol-position: right;/*移动到右边*/ +} +#qt_calendar_yearedit::down-button { /*往下的按钮*/ + width: 20px; + subcontrol-position: left; /*移动到左边去*/ +} + + +/*月份选择菜单*/ +CalendarWidget QToolButton QMenu { + background-color: white; +} +CalendarWidget QToolButton QMenu::item { + padding: 10px; +} +CalendarWidget QToolButton QMenu::item:selected:enabled { + background-color: rgb(230, 230, 230); +} +CalendarWidget QToolButton::menu-indicator { + /*image: none;去掉月份选择下面的小箭头*/ + subcontrol-position: right center;/*右边居中*/ +} + + +/*下方的日历表格*/ +#qt_calendar_calendarview { + outline: 0px;/*去掉选中后的虚线框*/ + selection-background-color: rgb(0, 188, 212); /*选中背景颜色*/ +} +''' + + +class CalendarWidget(QCalendarWidget): + + def __init__(self, *args, **kwargs): + super(CalendarWidget, self).__init__(*args, **kwargs) + # 隐藏左边的序号 + self.setVerticalHeaderFormat(self.NoVerticalHeader) + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setStyleSheet(StyleSheet) + w = CalendarWidget() + w.show() + sys.exit(app.exec_()) diff --git a/界面美化/QSS美化例子/QCalendarWidget日历/README.md b/美化/QCalendarWidget/README.md similarity index 97% rename from 界面美化/QSS美化例子/QCalendarWidget日历/README.md rename to 美化/QCalendarWidget/README.md index ec608c5..5a756cf 100644 --- a/界面美化/QSS美化例子/QCalendarWidget日历/README.md +++ b/美化/QCalendarWidget/README.md @@ -1,10 +1,10 @@ -# QCalendarWidget 日历控件 QSS 美化样式 - -主要改变顶部背景颜色和高度,上下月按钮、月份选择、年选择、菜单 - -详细美化都在代码里的QSS中注释了 - -效果图: - -### [CalendarWidget.py](CalendarWidget.py) +# QCalendarWidget 日历控件 QSS 美化样式 + +主要改变顶部背景颜色和高度,上下月按钮、月份选择、年选择、菜单 + +详细美化都在代码里的QSS中注释了 + +效果图: + +### [CalendarWidget.py](CalendarWidget.py) ![CalendarWidget](ScreenShot/CalendarWidget.gif) \ No newline at end of file diff --git a/界面美化/QSS美化例子/QCalendarWidget日历/ScreenShot/CalendarWidget.gif b/美化/QCalendarWidget/ScreenShot/CalendarWidget.gif similarity index 100% rename from 界面美化/QSS美化例子/QCalendarWidget日历/ScreenShot/CalendarWidget.gif rename to 美化/QCalendarWidget/ScreenShot/CalendarWidget.gif diff --git a/界面美化/QFileSystemModel图标/FileSystemModel.py b/美化/QFileSystemModel/FileSystemModel.py similarity index 96% rename from 界面美化/QFileSystemModel图标/FileSystemModel.py rename to 美化/QFileSystemModel/FileSystemModel.py index 5da87cb..0fbb869 100644 --- a/界面美化/QFileSystemModel图标/FileSystemModel.py +++ b/美化/QFileSystemModel/FileSystemModel.py @@ -1,82 +1,82 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月26日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: FileSystemModel -@description: -''' -import sys - -from PyQt5.QtCore import QFileInfo -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QFileSystemModel, QFileIconProvider, QApplication,\ - QTreeView - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -# 图标提供类 - - -class FileIconProvider(QFileIconProvider): - - def __init__(self, *args, **kwargs): - super(FileIconProvider, self).__init__(*args, **kwargs) - self.DirIcon = QIcon("icons/folder.png") - self.TxtIcon = QIcon("icons/file.png") - - def icon(self, type_info): - ''' - :param fileInfo: 参考http://doc.qt.io/qt-5/qfileinfo.html - ''' - if isinstance(type_info, QFileInfo): - # 如果type_info是QFileInfo类型则用getInfoIcon来返回图标 - return self.getInfoIcon(type_info) - # 如果type_info是QFileIconProvider自身的IconType枚举类型则执行下面的方法 - # 这里只能自定义通用的几种类型,参考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum - ''' - QFileIconProvider::Computer 0 - QFileIconProvider::Desktop 1 - QFileIconProvider::Trashcan 2 - QFileIconProvider::Network 3 - QFileIconProvider::Drive 4 - QFileIconProvider::Folder 5 - QFileIconProvider::File 6 - ''' - if type_info == QFileIconProvider.Folder: - # 如果是文件夹 - return self.DirIcon - return super(FileIconProvider, self).icon(type_info) - - def getInfoIcon(self, type_info): - if type_info.isDir(): # 文件夹 - return self.DirIcon - if type_info.isFile() and type_info.suffix() == "txt": # 文件并且是txt - return self.TxtIcon - return super(FileIconProvider, self).icon(type_info) - - -if __name__ == "__main__": - app = QApplication(sys.argv) - - model = QFileSystemModel() - model.setIconProvider(FileIconProvider()) # 设置为自定义的图标提供类 - model.setRootPath("") - tree = QTreeView() - tree.setModel(model) - - tree.setAnimated(False) - tree.setIndentation(20) - tree.setSortingEnabled(True) - - tree.setWindowTitle("Dir View") - tree.resize(640, 480) - tree.show() - - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月26日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: FileSystemModel +@description: +''' +import sys + +from PyQt5.QtCore import QFileInfo +from PyQt5.QtGui import QIcon +from PyQt5.QtWidgets import QFileSystemModel, QFileIconProvider, QApplication,\ + QTreeView + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +# 图标提供类 + + +class FileIconProvider(QFileIconProvider): + + def __init__(self, *args, **kwargs): + super(FileIconProvider, self).__init__(*args, **kwargs) + self.DirIcon = QIcon("icons/folder.png") + self.TxtIcon = QIcon("icons/file.png") + + def icon(self, type_info): + ''' + :param fileInfo: 参考http://doc.qt.io/qt-5/qfileinfo.html + ''' + if isinstance(type_info, QFileInfo): + # 如果type_info是QFileInfo类型则用getInfoIcon来返回图标 + return self.getInfoIcon(type_info) + # 如果type_info是QFileIconProvider自身的IconType枚举类型则执行下面的方法 + # 这里只能自定义通用的几种类型,参考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum + ''' + QFileIconProvider::Computer 0 + QFileIconProvider::Desktop 1 + QFileIconProvider::Trashcan 2 + QFileIconProvider::Network 3 + QFileIconProvider::Drive 4 + QFileIconProvider::Folder 5 + QFileIconProvider::File 6 + ''' + if type_info == QFileIconProvider.Folder: + # 如果是文件夹 + return self.DirIcon + return super(FileIconProvider, self).icon(type_info) + + def getInfoIcon(self, type_info): + if type_info.isDir(): # 文件夹 + return self.DirIcon + if type_info.isFile() and type_info.suffix() == "txt": # 文件并且是txt + return self.TxtIcon + return super(FileIconProvider, self).icon(type_info) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + + model = QFileSystemModel() + model.setIconProvider(FileIconProvider()) # 设置为自定义的图标提供类 + model.setRootPath("") + tree = QTreeView() + tree.setModel(model) + + tree.setAnimated(False) + tree.setIndentation(20) + tree.setSortingEnabled(True) + + tree.setWindowTitle("Dir View") + tree.resize(640, 480) + tree.show() + + sys.exit(app.exec_()) diff --git a/界面美化/QFileSystemModel图标/README.md b/美化/QFileSystemModel/README.md similarity index 96% rename from 界面美化/QFileSystemModel图标/README.md rename to 美化/QFileSystemModel/README.md index cef84e4..bf1a54f 100644 --- a/界面美化/QFileSystemModel图标/README.md +++ b/美化/QFileSystemModel/README.md @@ -1,11 +1,11 @@ -# QFileSystemModel 自定义图标 - -使用QFileSystemModel.setIconProvider(QFileIconProvider)来设置图标提供类 - -通过重写QFileIconProvider的icon方法来决定返回什么样的图标 - -见需求 [Issues#2](https://github.com/892768447/PyQt/issues/2) - -截图 - +# QFileSystemModel 自定义图标 + +使用QFileSystemModel.setIconProvider(QFileIconProvider)来设置图标提供类 + +通过重写QFileIconProvider的icon方法来决定返回什么样的图标 + +见需求 [Issues#2](https://github.com/892768447/PyQt/issues/2) + +截图 + ![1](ScreenShot/1.png) \ No newline at end of file diff --git a/界面美化/QFileSystemModel图标/ScreenShot/1.png b/美化/QFileSystemModel/ScreenShot/1.png similarity index 100% rename from 界面美化/QFileSystemModel图标/ScreenShot/1.png rename to 美化/QFileSystemModel/ScreenShot/1.png diff --git a/界面美化/QFileSystemModel图标/icons/file.png b/美化/QFileSystemModel/icons/file.png similarity index 100% rename from 界面美化/QFileSystemModel图标/icons/file.png rename to 美化/QFileSystemModel/icons/file.png diff --git a/界面美化/QFileSystemModel图标/icons/folder.png b/美化/QFileSystemModel/icons/folder.png similarity index 100% rename from 界面美化/QFileSystemModel图标/icons/folder.png rename to 美化/QFileSystemModel/icons/folder.png diff --git a/界面美化/QLabel圆形头像/head.jpg b/美化/QLabel/Images/head.jpg similarity index 100% rename from 界面美化/QLabel圆形头像/head.jpg rename to 美化/QLabel/Images/head.jpg diff --git a/界面美化/QLabel圆形头像/ScreenShot/1.png b/美化/QLabel/ScreenShot/圆形图片.png similarity index 100% rename from 界面美化/QLabel圆形头像/ScreenShot/1.png rename to 美化/QLabel/ScreenShot/圆形图片.png diff --git a/界面美化/QLabel圆形头像/CircleLabel.py b/美化/QLabel/圆形图片.py similarity index 93% rename from 界面美化/QLabel圆形头像/CircleLabel.py rename to 美化/QLabel/圆形图片.py index 86372d4..b604c4a 100644 --- a/界面美化/QLabel圆形头像/CircleLabel.py +++ b/美化/QLabel/圆形图片.py @@ -1,75 +1,75 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月20日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: CircleLabel -@description: -''' -from PyQt5.QtCore import Qt -from PyQt5.QtGui import QPixmap, QPainter, QPainterPath -from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - - -class Label(QLabel): - - def __init__(self, *args, antialiasing=True, **kwargs): - super(Label, self).__init__(*args, **kwargs) - self.Antialiasing = antialiasing - self.setMaximumSize(200, 200) - self.setMinimumSize(200, 200) - self.radius = 100 - - #####################核心实现######################### - self.target = QPixmap(self.size()) # 大小和控件一样 - self.target.fill(Qt.transparent) # 填充背景为透明 - - p = QPixmap("head.jpg").scaled( # 加载图片并缩放和控件一样大 - 200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation) - - painter = QPainter(self.target) - if self.Antialiasing: - # 抗锯齿 - painter.setRenderHint(QPainter.Antialiasing, True) - painter.setRenderHint(QPainter.HighQualityAntialiasing, True) - painter.setRenderHint(QPainter.SmoothPixmapTransform, True) - -# painter.setPen(# 测试圆圈 -# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) - path = QPainterPath() - path.addRoundedRect( - 0, 0, self.width(), self.height(), self.radius, self.radius) - #**** 切割为圆形 ****# - painter.setClipPath(path) -# painter.drawPath(path) # 测试圆圈 - - painter.drawPixmap(0, 0, p) - self.setPixmap(self.target) - #####################核心实现######################### - - -class Window(QWidget): - - def __init__(self, *args, **kwargs): - super(Window, self).__init__(*args, **kwargs) - layout = QHBoxLayout(self) - layout.addWidget(Label(self)) - layout.addWidget(Label(self, antialiasing=False)) - self.setStyleSheet("background: black;") - - -if __name__ == "__main__": - import sys - from PyQt5.QtWidgets import QApplication - app = QApplication(sys.argv) - w = Window() - w.show() - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月20日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: CircleLabel +@description: +''' +from PyQt5.QtCore import Qt +from PyQt5.QtGui import QPixmap, QPainter, QPainterPath +from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + + +class Label(QLabel): + + def __init__(self, *args, antialiasing=True, **kwargs): + super(Label, self).__init__(*args, **kwargs) + self.Antialiasing = antialiasing + self.setMaximumSize(200, 200) + self.setMinimumSize(200, 200) + self.radius = 100 + + #####################核心实现######################### + self.target = QPixmap(self.size()) # 大小和控件一样 + self.target.fill(Qt.transparent) # 填充背景为透明 + + p = QPixmap("Images/head.jpg").scaled( # 加载图片并缩放和控件一样大 + 200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation) + + painter = QPainter(self.target) + if self.Antialiasing: + # 抗锯齿 + painter.setRenderHint(QPainter.Antialiasing, True) + painter.setRenderHint(QPainter.HighQualityAntialiasing, True) + painter.setRenderHint(QPainter.SmoothPixmapTransform, True) + +# painter.setPen(# 测试圆圈 +# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) + path = QPainterPath() + path.addRoundedRect( + 0, 0, self.width(), self.height(), self.radius, self.radius) + #**** 切割为圆形 ****# + painter.setClipPath(path) +# painter.drawPath(path) # 测试圆圈 + + painter.drawPixmap(0, 0, p) + self.setPixmap(self.target) + #####################核心实现######################### + + +class Window(QWidget): + + def __init__(self, *args, **kwargs): + super(Window, self).__init__(*args, **kwargs) + layout = QHBoxLayout(self) + layout.addWidget(Label(self)) + layout.addWidget(Label(self, antialiasing=False)) + self.setStyleSheet("background: black;") + + +if __name__ == "__main__": + import sys + from PyQt5.QtWidgets import QApplication + app = QApplication(sys.argv) + w = Window() + w.show() + sys.exit(app.exec_()) diff --git a/界面美化/QMessageBox样式/README.md b/美化/QMessageBox/README.md similarity index 98% rename from 界面美化/QMessageBox样式/README.md rename to 美化/QMessageBox/README.md index 2fe5881..1e25fc4 100644 --- a/界面美化/QMessageBox样式/README.md +++ b/美化/QMessageBox/README.md @@ -1,11 +1,11 @@ -# 消息提示框的按钮和图标美化 - -### [1.方案一](方案一/) - - 1.1 该方案使用dialogbuttonbox-buttons-have-icons: 1; 开启自带的图标样式 - - 1.2 再利用dialog-xx-icon: url(); 来设置自定义的图标, 具体参考[list-of-icons](http://doc.qt.io/qt-5/stylesheet-reference.html#list-of-icons) - - 1.3 缺点 部分按钮图标无效,无法自定义不同按钮的颜色 - -### [2.方案二](方案二/) - - 2.1 采用样式表中的属性选择器 QPushButton[text="xxx"] 可以根据按钮中的文字来区分 - - 2.2 在利用属性样式qproperty-icon: url();来设置自定义图标 +# 消息提示框的按钮和图标美化 + +### [1.方案一](方案一/) + - 1.1 该方案使用dialogbuttonbox-buttons-have-icons: 1; 开启自带的图标样式 + - 1.2 再利用dialog-xx-icon: url(); 来设置自定义的图标, 具体参考[list-of-icons](http://doc.qt.io/qt-5/stylesheet-reference.html#list-of-icons) + - 1.3 缺点 部分按钮图标无效,无法自定义不同按钮的颜色 + +### [2.方案二](方案二/) + - 2.1 采用样式表中的属性选择器 QPushButton[text="xxx"] 可以根据按钮中的文字来区分 + - 2.2 在利用属性样式qproperty-icon: url();来设置自定义图标 - 2.3 解决方案一的缺点 \ No newline at end of file diff --git a/界面美化/QMessageBox样式/icons/Abort.png b/美化/QMessageBox/icons/Abort.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Abort.png rename to 美化/QMessageBox/icons/Abort.png diff --git a/界面美化/QMessageBox样式/icons/Apply.png b/美化/QMessageBox/icons/Apply.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Apply.png rename to 美化/QMessageBox/icons/Apply.png diff --git a/界面美化/QMessageBox样式/icons/Cancel.png b/美化/QMessageBox/icons/Cancel.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Cancel.png rename to 美化/QMessageBox/icons/Cancel.png diff --git a/界面美化/QMessageBox样式/icons/Close.png b/美化/QMessageBox/icons/Close.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Close.png rename to 美化/QMessageBox/icons/Close.png diff --git a/界面美化/QMessageBox样式/icons/Discard.png b/美化/QMessageBox/icons/Discard.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Discard.png rename to 美化/QMessageBox/icons/Discard.png diff --git a/界面美化/QMessageBox样式/icons/Help.png b/美化/QMessageBox/icons/Help.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Help.png rename to 美化/QMessageBox/icons/Help.png diff --git a/界面美化/QMessageBox样式/icons/Ignore.png b/美化/QMessageBox/icons/Ignore.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Ignore.png rename to 美化/QMessageBox/icons/Ignore.png diff --git a/界面美化/QMessageBox样式/icons/No.png b/美化/QMessageBox/icons/No.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/No.png rename to 美化/QMessageBox/icons/No.png diff --git a/界面美化/QMessageBox样式/icons/NoToAll.png b/美化/QMessageBox/icons/NoToAll.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/NoToAll.png rename to 美化/QMessageBox/icons/NoToAll.png diff --git a/界面美化/QMessageBox样式/icons/Ok.png b/美化/QMessageBox/icons/Ok.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Ok.png rename to 美化/QMessageBox/icons/Ok.png diff --git a/界面美化/QMessageBox样式/icons/Open.png b/美化/QMessageBox/icons/Open.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Open.png rename to 美化/QMessageBox/icons/Open.png diff --git a/界面美化/QMessageBox样式/icons/Reset.png b/美化/QMessageBox/icons/Reset.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Reset.png rename to 美化/QMessageBox/icons/Reset.png diff --git a/界面美化/QMessageBox样式/icons/RestoreDefaults.png b/美化/QMessageBox/icons/RestoreDefaults.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/RestoreDefaults.png rename to 美化/QMessageBox/icons/RestoreDefaults.png diff --git a/界面美化/QMessageBox样式/icons/Retry.png b/美化/QMessageBox/icons/Retry.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Retry.png rename to 美化/QMessageBox/icons/Retry.png diff --git a/界面美化/QMessageBox样式/icons/Save.png b/美化/QMessageBox/icons/Save.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Save.png rename to 美化/QMessageBox/icons/Save.png diff --git a/界面美化/QMessageBox样式/icons/SaveAll.png b/美化/QMessageBox/icons/SaveAll.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/SaveAll.png rename to 美化/QMessageBox/icons/SaveAll.png diff --git a/界面美化/QMessageBox样式/icons/Yes.png b/美化/QMessageBox/icons/Yes.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/Yes.png rename to 美化/QMessageBox/icons/Yes.png diff --git a/界面美化/QMessageBox样式/icons/YesToAll.png b/美化/QMessageBox/icons/YesToAll.png similarity index 100% rename from 界面美化/QMessageBox样式/icons/YesToAll.png rename to 美化/QMessageBox/icons/YesToAll.png diff --git a/界面美化/QMessageBox样式/方案一/README.md b/美化/QMessageBox/方案一/README.md similarity index 96% rename from 界面美化/QMessageBox样式/方案一/README.md rename to 美化/QMessageBox/方案一/README.md index ec78ff6..82f9cf0 100644 --- a/界面美化/QMessageBox样式/方案一/README.md +++ b/美化/QMessageBox/方案一/README.md @@ -1,7 +1,7 @@ -# 方案一 - -截图 -![critical](ScreenShot/critical.png) -![information](ScreenShot/information.png) -![question](ScreenShot/question.png) +# 方案一 + +截图 +![critical](ScreenShot/critical.png) +![information](ScreenShot/information.png) +![question](ScreenShot/question.png) ![warning](ScreenShot/warning.png) \ No newline at end of file diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/critical.png b/美化/QMessageBox/方案一/ScreenShot/critical.png similarity index 100% rename from 界面美化/QMessageBox样式/方案一/ScreenShot/critical.png rename to 美化/QMessageBox/方案一/ScreenShot/critical.png diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/information.png b/美化/QMessageBox/方案一/ScreenShot/information.png similarity index 100% rename from 界面美化/QMessageBox样式/方案一/ScreenShot/information.png rename to 美化/QMessageBox/方案一/ScreenShot/information.png diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/question.png b/美化/QMessageBox/方案一/ScreenShot/question.png similarity index 100% rename from 界面美化/QMessageBox样式/方案一/ScreenShot/question.png rename to 美化/QMessageBox/方案一/ScreenShot/question.png diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/warning.png b/美化/QMessageBox/方案一/ScreenShot/warning.png similarity index 100% rename from 界面美化/QMessageBox样式/方案一/ScreenShot/warning.png rename to 美化/QMessageBox/方案一/ScreenShot/warning.png diff --git a/界面美化/QMessageBox样式/方案一/critical.py b/美化/QMessageBox/方案一/critical.py similarity index 96% rename from 界面美化/QMessageBox样式/方案一/critical.py rename to 美化/QMessageBox/方案一/critical.py index 8f8e0a2..aa99bc8 100644 --- a/界面美化/QMessageBox样式/方案一/critical.py +++ b/美化/QMessageBox/方案一/critical.py @@ -1,40 +1,40 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: critical -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet('''QDialogButtonBox { - dialogbuttonbox-buttons-have-icons: 1; - dialog-ok-icon: url(../icons/Ok.png); - dialog-open-icon: url(../icons/Open.png); - dialog-save-icon: url(../icons/Save.png); - dialog-cancel-icon: url(../icons/Cancel.png); -} - -QMessageBox { - messagebox-critical-icon: url(../icons/Close.png); -} -''') -QMessageBox.critical(None, "提示critical", "消息", - QMessageBox.Ok | - QMessageBox.Open | - QMessageBox.Save | - QMessageBox.Cancel) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: critical +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet('''QDialogButtonBox { + dialogbuttonbox-buttons-have-icons: 1; + dialog-ok-icon: url(../icons/Ok.png); + dialog-open-icon: url(../icons/Open.png); + dialog-save-icon: url(../icons/Save.png); + dialog-cancel-icon: url(../icons/Cancel.png); +} + +QMessageBox { + messagebox-critical-icon: url(../icons/Close.png); +} +''') +QMessageBox.critical(None, "提示critical", "消息", + QMessageBox.Ok | + QMessageBox.Open | + QMessageBox.Save | + QMessageBox.Cancel) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案一/information.py b/美化/QMessageBox/方案一/information.py similarity index 96% rename from 界面美化/QMessageBox样式/方案一/information.py rename to 美化/QMessageBox/方案一/information.py index f490c80..6d4939a 100644 --- a/界面美化/QMessageBox样式/方案一/information.py +++ b/美化/QMessageBox/方案一/information.py @@ -1,40 +1,40 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: information -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet('''QDialogButtonBox { - dialogbuttonbox-buttons-have-icons: 1; - dialog-close-icon: url(../icons/Close.png); - dialog-discard-icon: url(../icons/Discard.png); - dialog-apply-icon: url(../icons/Apply.png); - dialog-reset-icon: url(../icons/Reset.png); -} - -QMessageBox { - messagebox-information-icon: url(../icons/Ok.png); -} -''') -QMessageBox.information(None, "提示information", "消息", - QMessageBox.Close | - QMessageBox.Discard | - QMessageBox.Apply | - QMessageBox.Reset) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: information +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet('''QDialogButtonBox { + dialogbuttonbox-buttons-have-icons: 1; + dialog-close-icon: url(../icons/Close.png); + dialog-discard-icon: url(../icons/Discard.png); + dialog-apply-icon: url(../icons/Apply.png); + dialog-reset-icon: url(../icons/Reset.png); +} + +QMessageBox { + messagebox-information-icon: url(../icons/Ok.png); +} +''') +QMessageBox.information(None, "提示information", "消息", + QMessageBox.Close | + QMessageBox.Discard | + QMessageBox.Apply | + QMessageBox.Reset) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案一/question.py b/美化/QMessageBox/方案一/question.py similarity index 96% rename from 界面美化/QMessageBox样式/方案一/question.py rename to 美化/QMessageBox/方案一/question.py index 6c37319..7f16373 100644 --- a/界面美化/QMessageBox样式/方案一/question.py +++ b/美化/QMessageBox/方案一/question.py @@ -1,39 +1,39 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: question -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet('''QDialogButtonBox { - dialogbuttonbox-buttons-have-icons: 1; - dialog-help-icon: url(../icons/Help.png); - dialog-yes-icon: url(../icons/Yes.png); -} - -QMessageBox { - messagebox-question-icon: url(../icons/Ok.png); -} -''') -QMessageBox.question(None, "提示question", "消息", - QMessageBox.RestoreDefaults | - QMessageBox.Help | - QMessageBox.SaveAll | - QMessageBox.Yes | - QMessageBox.YesToAll) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: question +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet('''QDialogButtonBox { + dialogbuttonbox-buttons-have-icons: 1; + dialog-help-icon: url(../icons/Help.png); + dialog-yes-icon: url(../icons/Yes.png); +} + +QMessageBox { + messagebox-question-icon: url(../icons/Ok.png); +} +''') +QMessageBox.question(None, "提示question", "消息", + QMessageBox.RestoreDefaults | + QMessageBox.Help | + QMessageBox.SaveAll | + QMessageBox.Yes | + QMessageBox.YesToAll) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案一/warning.py b/美化/QMessageBox/方案一/warning.py similarity index 96% rename from 界面美化/QMessageBox样式/方案一/warning.py rename to 美化/QMessageBox/方案一/warning.py index 2dc9723..d83b933 100644 --- a/界面美化/QMessageBox样式/方案一/warning.py +++ b/美化/QMessageBox/方案一/warning.py @@ -1,39 +1,39 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: warning -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox -app = QApplication(sys.argv) -app.setStyleSheet('''QDialogButtonBox { - dialogbuttonbox-buttons-have-icons: 1; - dialog-no-icon: url(../icons/No.png); - dialog-abort-icon: url(../icons/Abort.png); - dialog-retry-icon: url(../icons/Retry.png); - dialog-ignore-icon: url(../icons/Ignore.png); -} - -QMessageBox { - messagebox-warning-icon: url(../icons/Ok.png); -} -''') -QMessageBox.warning(None, "提示warning", "消息", - QMessageBox.No | - QMessageBox.NoToAll | - QMessageBox.Abort | - QMessageBox.Retry | - QMessageBox.Ignore) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: warning +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox +app = QApplication(sys.argv) +app.setStyleSheet('''QDialogButtonBox { + dialogbuttonbox-buttons-have-icons: 1; + dialog-no-icon: url(../icons/No.png); + dialog-abort-icon: url(../icons/Abort.png); + dialog-retry-icon: url(../icons/Retry.png); + dialog-ignore-icon: url(../icons/Ignore.png); +} + +QMessageBox { + messagebox-warning-icon: url(../icons/Ok.png); +} +''') +QMessageBox.warning(None, "提示warning", "消息", + QMessageBox.No | + QMessageBox.NoToAll | + QMessageBox.Abort | + QMessageBox.Retry | + QMessageBox.Ignore) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案二/README.md b/美化/QMessageBox/方案二/README.md similarity index 96% rename from 界面美化/QMessageBox样式/方案二/README.md rename to 美化/QMessageBox/方案二/README.md index 1133397..6ec0aec 100644 --- a/界面美化/QMessageBox样式/方案二/README.md +++ b/美化/QMessageBox/方案二/README.md @@ -1,7 +1,7 @@ -# 方案二 - -截图 -![critical](ScreenShot/critical.png) -![information](ScreenShot/information.png) -![question](ScreenShot/question.png) +# 方案二 + +截图 +![critical](ScreenShot/critical.png) +![information](ScreenShot/information.png) +![question](ScreenShot/question.png) ![warning](ScreenShot/warning.png) \ No newline at end of file diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/critical.png b/美化/QMessageBox/方案二/ScreenShot/critical.png similarity index 100% rename from 界面美化/QMessageBox样式/方案二/ScreenShot/critical.png rename to 美化/QMessageBox/方案二/ScreenShot/critical.png diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/information.png b/美化/QMessageBox/方案二/ScreenShot/information.png similarity index 100% rename from 界面美化/QMessageBox样式/方案二/ScreenShot/information.png rename to 美化/QMessageBox/方案二/ScreenShot/information.png diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/question.png b/美化/QMessageBox/方案二/ScreenShot/question.png similarity index 100% rename from 界面美化/QMessageBox样式/方案二/ScreenShot/question.png rename to 美化/QMessageBox/方案二/ScreenShot/question.png diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/warning.png b/美化/QMessageBox/方案二/ScreenShot/warning.png similarity index 100% rename from 界面美化/QMessageBox样式/方案二/ScreenShot/warning.png rename to 美化/QMessageBox/方案二/ScreenShot/warning.png diff --git a/界面美化/QMessageBox样式/方案二/critical.py b/美化/QMessageBox/方案二/critical.py similarity index 95% rename from 界面美化/QMessageBox样式/方案二/critical.py rename to 美化/QMessageBox/方案二/critical.py index 664415d..22c277f 100644 --- a/界面美化/QMessageBox样式/方案二/critical.py +++ b/美化/QMessageBox/方案二/critical.py @@ -1,71 +1,71 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: critical -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet(''' -QPushButton[text="OK"] { - background: red; - qproperty-icon: url(../icons/Ok.png); -} -QPushButton[text="OK"]:hover { - background: darkRed; -} - -QPushButton[text="Open"] { - background: green; - qproperty-icon: url(../icons/Open.png); -} -QPushButton[text="Open"]:hover { - background: darkGreen; -} - -QPushButton[text="Save"] { - background: blue; - qproperty-icon: url(../icons/Save.png); -} -QPushButton[text="Save"]:hover { - background: darkBlue; -} - -QPushButton[text="Cancel"] { - background: cyan; - qproperty-icon: url(../icons/Cancel.png); -} -QPushButton[text="Cancel"]:hover { - background: darkCyan; -} - -QMessageBox { - messagebox-critical-icon: url(../icons/Close.png); -} - -QMessageBox QPushButton { - min-width: 95px; - min-height: 30px; - border-radius: 5px; -} -''') -QMessageBox.critical(None, "提示critical", "消息", - QMessageBox.Ok | - QMessageBox.Open | - QMessageBox.Save | - QMessageBox.Cancel) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: critical +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet(''' +QPushButton[text="OK"] { + background: red; + qproperty-icon: url(../icons/Ok.png); +} +QPushButton[text="OK"]:hover { + background: darkRed; +} + +QPushButton[text="Open"] { + background: green; + qproperty-icon: url(../icons/Open.png); +} +QPushButton[text="Open"]:hover { + background: darkGreen; +} + +QPushButton[text="Save"] { + background: blue; + qproperty-icon: url(../icons/Save.png); +} +QPushButton[text="Save"]:hover { + background: darkBlue; +} + +QPushButton[text="Cancel"] { + background: cyan; + qproperty-icon: url(../icons/Cancel.png); +} +QPushButton[text="Cancel"]:hover { + background: darkCyan; +} + +QMessageBox { + messagebox-critical-icon: url(../icons/Close.png); +} + +QMessageBox QPushButton { + min-width: 95px; + min-height: 30px; + border-radius: 5px; +} +''') +QMessageBox.critical(None, "提示critical", "消息", + QMessageBox.Ok | + QMessageBox.Open | + QMessageBox.Save | + QMessageBox.Cancel) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案二/information.py b/美化/QMessageBox/方案二/information.py similarity index 95% rename from 界面美化/QMessageBox样式/方案二/information.py rename to 美化/QMessageBox/方案二/information.py index 40df83e..7e2a5f8 100644 --- a/界面美化/QMessageBox样式/方案二/information.py +++ b/美化/QMessageBox/方案二/information.py @@ -1,71 +1,71 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: information -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet(''' -QPushButton[text="Close"] { - background: red; - qproperty-icon: url(../icons/Close.png); -} -QPushButton[text="Close"]:hover { - background: darkRed; -} - -QPushButton[text="Discard"] { - background: green; - qproperty-icon: url(../icons/Discard.png); -} -QPushButton[text="Discard"]:hover { - background: darkGreen; -} - -QPushButton[text="Apply"] { - background: blue; - qproperty-icon: url(../icons/Apply.png); -} -QPushButton[text="Apply"]:hover { - background: darkBlue; -} - -QPushButton[text="Reset"] { - background: cyan; - qproperty-icon: url(../icons/Reset.png); -} -QPushButton[text="Reset"]:hover { - background: darkCyan; -} - -QMessageBox { - messagebox-information-icon: url(../icons/Close.png); -} - -QMessageBox QPushButton { - min-width: 95px; - min-height: 30px; - border-radius: 5px; -} -''') -QMessageBox.information(None, "提示information", "消息", - QMessageBox.Close | - QMessageBox.Discard | - QMessageBox.Apply | - QMessageBox.Reset) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: information +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet(''' +QPushButton[text="Close"] { + background: red; + qproperty-icon: url(../icons/Close.png); +} +QPushButton[text="Close"]:hover { + background: darkRed; +} + +QPushButton[text="Discard"] { + background: green; + qproperty-icon: url(../icons/Discard.png); +} +QPushButton[text="Discard"]:hover { + background: darkGreen; +} + +QPushButton[text="Apply"] { + background: blue; + qproperty-icon: url(../icons/Apply.png); +} +QPushButton[text="Apply"]:hover { + background: darkBlue; +} + +QPushButton[text="Reset"] { + background: cyan; + qproperty-icon: url(../icons/Reset.png); +} +QPushButton[text="Reset"]:hover { + background: darkCyan; +} + +QMessageBox { + messagebox-information-icon: url(../icons/Close.png); +} + +QMessageBox QPushButton { + min-width: 95px; + min-height: 30px; + border-radius: 5px; +} +''') +QMessageBox.information(None, "提示information", "消息", + QMessageBox.Close | + QMessageBox.Discard | + QMessageBox.Apply | + QMessageBox.Reset) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案二/question.py b/美化/QMessageBox/方案二/question.py similarity index 95% rename from 界面美化/QMessageBox样式/方案二/question.py rename to 美化/QMessageBox/方案二/question.py index bd81c43..deb5cd5 100644 --- a/界面美化/QMessageBox样式/方案二/question.py +++ b/美化/QMessageBox/方案二/question.py @@ -1,80 +1,80 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: question -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet(''' -QPushButton[text="Restore Defaults"] { - background: red; - qproperty-icon: url(../icons/RestoreDefaults.png); -} -QPushButton[text="Restore Defaults"]:hover { - background: darkRed; -} - -QPushButton[text="Help"] { - background: green; - qproperty-icon: url(../icons/Help.png); -} -QPushButton[text="Help"]:hover { - background: darkGreen; -} - -QPushButton[text="Save All"] { - background: blue; - qproperty-icon: url(../icons/SaveAll.png); -} -QPushButton[text="Save All"]:hover { - background: darkBlue; -} - -QPushButton[text="&Yes"] { - background: cyan; - qproperty-icon: url(../icons/Yes.png); -} -QPushButton[text="&Yes"]:hover { - background: darkCyan; -} - -QPushButton[text="Yes to &All"] { - background: magenta; - qproperty-icon: url(../icons/YesToAll.png); -} -QPushButton[text="Yes to &All"]:hover { - background: darkMegenta; -} - -QMessageBox { - messagebox-question-icon: url(../icons/Close.png); -} - -QMessageBox QPushButton { - min-width: 95px; - min-height: 30px; - border-radius: 5px; -} -''') -QMessageBox.question(None, "提示question", "消息", - QMessageBox.RestoreDefaults | - QMessageBox.Help | - QMessageBox.SaveAll | - QMessageBox.Yes | - QMessageBox.YesToAll) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: question +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet(''' +QPushButton[text="Restore Defaults"] { + background: red; + qproperty-icon: url(../icons/RestoreDefaults.png); +} +QPushButton[text="Restore Defaults"]:hover { + background: darkRed; +} + +QPushButton[text="Help"] { + background: green; + qproperty-icon: url(../icons/Help.png); +} +QPushButton[text="Help"]:hover { + background: darkGreen; +} + +QPushButton[text="Save All"] { + background: blue; + qproperty-icon: url(../icons/SaveAll.png); +} +QPushButton[text="Save All"]:hover { + background: darkBlue; +} + +QPushButton[text="&Yes"] { + background: cyan; + qproperty-icon: url(../icons/Yes.png); +} +QPushButton[text="&Yes"]:hover { + background: darkCyan; +} + +QPushButton[text="Yes to &All"] { + background: magenta; + qproperty-icon: url(../icons/YesToAll.png); +} +QPushButton[text="Yes to &All"]:hover { + background: darkMegenta; +} + +QMessageBox { + messagebox-question-icon: url(../icons/Close.png); +} + +QMessageBox QPushButton { + min-width: 95px; + min-height: 30px; + border-radius: 5px; +} +''') +QMessageBox.question(None, "提示question", "消息", + QMessageBox.RestoreDefaults | + QMessageBox.Help | + QMessageBox.SaveAll | + QMessageBox.Yes | + QMessageBox.YesToAll) +sys.exit() diff --git a/界面美化/QMessageBox样式/方案二/warning.py b/美化/QMessageBox/方案二/warning.py similarity index 95% rename from 界面美化/QMessageBox样式/方案二/warning.py rename to 美化/QMessageBox/方案二/warning.py index 2ea60c7..349dcfe 100644 --- a/界面美化/QMessageBox样式/方案二/warning.py +++ b/美化/QMessageBox/方案二/warning.py @@ -1,84 +1,84 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月17日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: warning -@description: -''' - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -import sys - -from PyQt5.QtWidgets import QApplication, QMessageBox - - -app = QApplication(sys.argv) -app.setStyleSheet(''' -QPushButton[text="&No"] { - background: red; - qproperty-icon: url(../icons/No.png); -} -QPushButton[text="&No"]:hover { - background: darkRed; -} - -QPushButton[text="N&o to All"] { - background: green; - qproperty-icon: url(../icons/NoToAll.png); -} -QPushButton[text="N&o to All"]:hover { - background: darkGreen; -} - -QPushButton[text="Abort"] { - background: blue; - qproperty-icon: url(../icons/Abort.png); -} -QPushButton[text="Abort"]:hover { - background: darkBlue; -} - -QPushButton[text="Retry"] { - background: cyan; - qproperty-icon: url(../icons/Retry.png); -} -QPushButton[text="Retry"]:hover { - background: darkCyan; -} - -QPushButton[text="Ignore"] { - background: magenta; - qproperty-icon: url(../icons/Ignore.png); -} -QPushButton[text="Ignore"]:hover { - background: darkMegenta; -} - -QMessageBox { - messagebox-warning-icon: url(../icons/No.png); -} - -QMessageBox QPushButton { - min-width: 95px; - min-height: 30px; - border-radius: 5px; -} - -QMessageBox QLabel { - color: red; -} -''') -QMessageBox.warning(None, "提示warning", "消息", - QMessageBox.No | - QMessageBox.NoToAll | - QMessageBox.Abort | - QMessageBox.Retry | - QMessageBox.Ignore) -sys.exit() +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月17日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: warning +@description: +''' + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +import sys + +from PyQt5.QtWidgets import QApplication, QMessageBox + + +app = QApplication(sys.argv) +app.setStyleSheet(''' +QPushButton[text="&No"] { + background: red; + qproperty-icon: url(../icons/No.png); +} +QPushButton[text="&No"]:hover { + background: darkRed; +} + +QPushButton[text="N&o to All"] { + background: green; + qproperty-icon: url(../icons/NoToAll.png); +} +QPushButton[text="N&o to All"]:hover { + background: darkGreen; +} + +QPushButton[text="Abort"] { + background: blue; + qproperty-icon: url(../icons/Abort.png); +} +QPushButton[text="Abort"]:hover { + background: darkBlue; +} + +QPushButton[text="Retry"] { + background: cyan; + qproperty-icon: url(../icons/Retry.png); +} +QPushButton[text="Retry"]:hover { + background: darkCyan; +} + +QPushButton[text="Ignore"] { + background: magenta; + qproperty-icon: url(../icons/Ignore.png); +} +QPushButton[text="Ignore"]:hover { + background: darkMegenta; +} + +QMessageBox { + messagebox-warning-icon: url(../icons/No.png); +} + +QMessageBox QPushButton { + min-width: 95px; + min-height: 30px; + border-radius: 5px; +} + +QMessageBox QLabel { + color: red; +} +''') +QMessageBox.warning(None, "提示warning", "消息", + QMessageBox.No | + QMessageBox.NoToAll | + QMessageBox.Abort | + QMessageBox.Retry | + QMessageBox.Ignore) +sys.exit() diff --git a/界面美化/QSS美化例子/QProgressBar进度条样式/ProgressBar.py b/美化/QProgressBar/ProgressBar.py similarity index 96% rename from 界面美化/QSS美化例子/QProgressBar进度条样式/ProgressBar.py rename to 美化/QProgressBar/ProgressBar.py index 4c62000..370013d 100644 --- a/界面美化/QSS美化例子/QProgressBar进度条样式/ProgressBar.py +++ b/美化/QProgressBar/ProgressBar.py @@ -1,105 +1,105 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月30日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: ProgressBar -@description: -''' -from random import randint -import sys - -from PyQt5.QtCore import QTimer -from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QProgressBar - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -StyleSheet = ''' -/*设置红色进度条*/ -#RedProgressBar { - text-align: center; /*进度值居中*/ -} -#RedProgressBar::chunk { - background-color: #F44336; -} - - -#GreenProgressBar { - min-height: 12px; - max-height: 12px; - border-radius: 6px; -} -#GreenProgressBar::chunk { - border-radius: 6px; - background-color: #009688; -} - -#BlueProgressBar { - border: 2px solid #2196F3;/*边框以及边框颜色*/ - border-radius: 5px; - background-color: #E0E0E0; -} -#BlueProgressBar::chunk { - background-color: #2196F3; - width: 10px; /*区块宽度*/ - margin: 0.5px; -} -''' - - -class ProgressBar(QProgressBar): - - def __init__(self, *args, **kwargs): - super(ProgressBar, self).__init__(*args, **kwargs) - self.setValue(0) - if self.minimum() != self.maximum(): - self.timer = QTimer(self, timeout=self.onTimeout) - self.timer.start(randint(1, 3) * 1000) - - def onTimeout(self): - if self.value() >= 100: - self.timer.stop() - self.timer.deleteLater() - del self.timer - return - self.setValue(self.value() + 1) - - -class Window(QWidget): - - def __init__(self, *args, **kwargs): - super(Window, self).__init__(*args, **kwargs) - self.resize(800, 600) - layout = QVBoxLayout(self) - layout.addWidget( - ProgressBar(self, minimum=0, maximum=100, objectName="RedProgressBar")) - layout.addWidget( # 繁忙状态 - ProgressBar(self, minimum=0, maximum=0, objectName="RedProgressBar")) - - layout.addWidget( - ProgressBar(self, minimum=0, maximum=100, textVisible=False, - objectName="GreenProgressBar")) - layout.addWidget( - ProgressBar(self, minimum=0, maximum=0, textVisible=False, - objectName="GreenProgressBar")) - - layout.addWidget( - ProgressBar(self, minimum=0, maximum=100, textVisible=False, - objectName="BlueProgressBar")) - layout.addWidget( - ProgressBar(self, minimum=0, maximum=0, textVisible=False, - objectName="BlueProgressBar")) - - -if __name__ == "__main__": - app = QApplication(sys.argv) - app.setStyleSheet(StyleSheet) - w = Window() - w.show() - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月30日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: ProgressBar +@description: +''' +from random import randint +import sys + +from PyQt5.QtCore import QTimer +from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QProgressBar + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +StyleSheet = ''' +/*设置红色进度条*/ +#RedProgressBar { + text-align: center; /*进度值居中*/ +} +#RedProgressBar::chunk { + background-color: #F44336; +} + + +#GreenProgressBar { + min-height: 12px; + max-height: 12px; + border-radius: 6px; +} +#GreenProgressBar::chunk { + border-radius: 6px; + background-color: #009688; +} + +#BlueProgressBar { + border: 2px solid #2196F3;/*边框以及边框颜色*/ + border-radius: 5px; + background-color: #E0E0E0; +} +#BlueProgressBar::chunk { + background-color: #2196F3; + width: 10px; /*区块宽度*/ + margin: 0.5px; +} +''' + + +class ProgressBar(QProgressBar): + + def __init__(self, *args, **kwargs): + super(ProgressBar, self).__init__(*args, **kwargs) + self.setValue(0) + if self.minimum() != self.maximum(): + self.timer = QTimer(self, timeout=self.onTimeout) + self.timer.start(randint(1, 3) * 1000) + + def onTimeout(self): + if self.value() >= 100: + self.timer.stop() + self.timer.deleteLater() + del self.timer + return + self.setValue(self.value() + 1) + + +class Window(QWidget): + + def __init__(self, *args, **kwargs): + super(Window, self).__init__(*args, **kwargs) + self.resize(800, 600) + layout = QVBoxLayout(self) + layout.addWidget( + ProgressBar(self, minimum=0, maximum=100, objectName="RedProgressBar")) + layout.addWidget( # 繁忙状态 + ProgressBar(self, minimum=0, maximum=0, objectName="RedProgressBar")) + + layout.addWidget( + ProgressBar(self, minimum=0, maximum=100, textVisible=False, + objectName="GreenProgressBar")) + layout.addWidget( + ProgressBar(self, minimum=0, maximum=0, textVisible=False, + objectName="GreenProgressBar")) + + layout.addWidget( + ProgressBar(self, minimum=0, maximum=100, textVisible=False, + objectName="BlueProgressBar")) + layout.addWidget( + ProgressBar(self, minimum=0, maximum=0, textVisible=False, + objectName="BlueProgressBar")) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setStyleSheet(StyleSheet) + w = Window() + w.show() + sys.exit(app.exec_()) diff --git a/界面美化/QSS美化例子/QProgressBar进度条样式/README.md b/美化/QProgressBar/README.md similarity index 96% rename from 界面美化/QSS美化例子/QProgressBar进度条样式/README.md rename to 美化/QProgressBar/README.md index b7df923..8529784 100644 --- a/界面美化/QSS美化例子/QProgressBar进度条样式/README.md +++ b/美化/QProgressBar/README.md @@ -1,10 +1,10 @@ -# QProgressBar进度条 QSS 美化样式 - -主要改变背景颜色、高度、边框、块颜色、边框、圆角 - -详细美化都在代码里的QSS中注释了 - -效果图: - -### [ProgressBar.py](ProgressBar.py) +# QProgressBar进度条 QSS 美化样式 + +主要改变背景颜色、高度、边框、块颜色、边框、圆角 + +详细美化都在代码里的QSS中注释了 + +效果图: + +### [ProgressBar.py](ProgressBar.py) ![ProgressBar](ScreenShot/ProgressBar.gif) \ No newline at end of file diff --git a/界面美化/QSS美化例子/QProgressBar进度条样式/ScreenShot/ProgressBar.gif b/美化/QProgressBar/ScreenShot/ProgressBar.gif similarity index 100% rename from 界面美化/QSS美化例子/QProgressBar进度条样式/ScreenShot/ProgressBar.gif rename to 美化/QProgressBar/ScreenShot/ProgressBar.gif diff --git a/界面美化/QSS美化例子/QPushButton按钮/ScreenShot/ButtonHover.gif b/美化/QPushButton/ScreenShot/按钮常见样式.gif similarity index 100% rename from 界面美化/QSS美化例子/QPushButton按钮/ScreenShot/ButtonHover.gif rename to 美化/QPushButton/ScreenShot/按钮常见样式.gif diff --git a/界面美化/QSS美化例子/QPushButton按钮/ButtonHover.py b/美化/QPushButton/按钮常见样式.py similarity index 96% rename from 界面美化/QSS美化例子/QPushButton按钮/ButtonHover.py rename to 美化/QPushButton/按钮常见样式.py index 8b67107..38716af 100644 --- a/界面美化/QSS美化例子/QPushButton按钮/ButtonHover.py +++ b/美化/QPushButton/按钮常见样式.py @@ -1,113 +1,113 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月29日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: ButtonHover -@description: -''' -import sys -from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -StyleSheet = ''' -/*这里是通用设置,所有按钮都有效,不过后面的可以覆盖这个*/ -QPushButton { - border: none; /*去掉边框*/ -} - -/* -QPushButton#xxx -或者 -#xx -都表示通过设置的objectName来指定 -*/ -QPushButton#RedButton { - background-color: #f44336; /*背景颜色*/ -} -#RedButton:hover { - background-color: #e57373; /*鼠标悬停时背景颜色*/ -} -/*注意pressed一定要放在hover的后面,否则没有效果*/ -#RedButton:pressed { - background-color: #ffcdd2; /*鼠标按下不放时背景颜色*/ -} - -#GreenButton { - background-color: #4caf50; - border-radius: 5px; /*圆角*/ -} -#GreenButton:hover { - background-color: #81c784; -} -#GreenButton:pressed { - background-color: #c8e6c9; -} - -#BlueButton { - background-color: #2196f3; - /*限制最小最大尺寸*/ - min-width: 96px; - max-width: 96px; - min-height: 96px; - max-height: 96px; - border-radius: 48px; /*圆形*/ -} -#BlueButton:hover { - background-color: #64b5f6; -} -#BlueButton:pressed { - background-color: #bbdefb; -} - -#OrangeButton { - max-height: 48px; - border-top-right-radius: 20px; /*右上角圆角*/ - border-bottom-left-radius: 20px; /*左下角圆角*/ - background-color: #ff9800; -} -#OrangeButton:hover { - background-color: #ffb74d; -} -#OrangeButton:pressed { - background-color: #ffe0b2; -} - -/*根据文字内容来区分按钮,同理还可以根据其它属性来区分*/ -QPushButton[text="purple button"] { - color: white; /*文字颜色*/ - background-color: #9c27b0; -} -''' - - -class Window(QWidget): - - def __init__(self, *args, **kwargs): - super(Window, self).__init__(*args, **kwargs) - layout = QHBoxLayout(self) - layout.addWidget(QPushButton("red button", self, - objectName="RedButton", minimumHeight=48)) - layout.addWidget(QPushButton("green button", self, - objectName="GreenButton", minimumHeight=48)) - layout.addWidget(QPushButton("blue button", self, - objectName="BlueButton", minimumHeight=48)) - layout.addWidget(QPushButton("orange button", self, - objectName="OrangeButton", minimumHeight=48)) - layout.addWidget(QPushButton("purple button", self, - objectName="PurpleButton", minimumHeight=48)) - - -if __name__ == "__main__": - app = QApplication(sys.argv) - app.setStyleSheet(StyleSheet) - w = Window() - w.show() - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月29日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: ButtonHover +@description: +''' +import sys +from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +StyleSheet = ''' +/*这里是通用设置,所有按钮都有效,不过后面的可以覆盖这个*/ +QPushButton { + border: none; /*去掉边框*/ +} + +/* +QPushButton#xxx +或者 +#xx +都表示通过设置的objectName来指定 +*/ +QPushButton#RedButton { + background-color: #f44336; /*背景颜色*/ +} +#RedButton:hover { + background-color: #e57373; /*鼠标悬停时背景颜色*/ +} +/*注意pressed一定要放在hover的后面,否则没有效果*/ +#RedButton:pressed { + background-color: #ffcdd2; /*鼠标按下不放时背景颜色*/ +} + +#GreenButton { + background-color: #4caf50; + border-radius: 5px; /*圆角*/ +} +#GreenButton:hover { + background-color: #81c784; +} +#GreenButton:pressed { + background-color: #c8e6c9; +} + +#BlueButton { + background-color: #2196f3; + /*限制最小最大尺寸*/ + min-width: 96px; + max-width: 96px; + min-height: 96px; + max-height: 96px; + border-radius: 48px; /*圆形*/ +} +#BlueButton:hover { + background-color: #64b5f6; +} +#BlueButton:pressed { + background-color: #bbdefb; +} + +#OrangeButton { + max-height: 48px; + border-top-right-radius: 20px; /*右上角圆角*/ + border-bottom-left-radius: 20px; /*左下角圆角*/ + background-color: #ff9800; +} +#OrangeButton:hover { + background-color: #ffb74d; +} +#OrangeButton:pressed { + background-color: #ffe0b2; +} + +/*根据文字内容来区分按钮,同理还可以根据其它属性来区分*/ +QPushButton[text="purple button"] { + color: white; /*文字颜色*/ + background-color: #9c27b0; +} +''' + + +class Window(QWidget): + + def __init__(self, *args, **kwargs): + super(Window, self).__init__(*args, **kwargs) + layout = QHBoxLayout(self) + layout.addWidget(QPushButton("red button", self, + objectName="RedButton", minimumHeight=48)) + layout.addWidget(QPushButton("green button", self, + objectName="GreenButton", minimumHeight=48)) + layout.addWidget(QPushButton("blue button", self, + objectName="BlueButton", minimumHeight=48)) + layout.addWidget(QPushButton("orange button", self, + objectName="OrangeButton", minimumHeight=48)) + layout.addWidget(QPushButton("purple button", self, + objectName="PurpleButton", minimumHeight=48)) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setStyleSheet(StyleSheet) + w = Window() + w.show() + sys.exit(app.exec_()) diff --git a/界面美化/QPushButton进度动画/Fonts/FontAwesome/fontawesome-webfont.ttf b/美化/QPushButton/按钮进度动画/Fonts/FontAwesome/fontawesome-webfont.ttf similarity index 100% rename from 界面美化/QPushButton进度动画/Fonts/FontAwesome/fontawesome-webfont.ttf rename to 美化/QPushButton/按钮进度动画/Fonts/FontAwesome/fontawesome-webfont.ttf diff --git a/界面美化/QPushButton进度动画/ScreenShot/1.gif b/美化/QPushButton/按钮进度动画/ScreenShot/按钮字体旋转动画.gif similarity index 100% rename from 界面美化/QPushButton进度动画/ScreenShot/1.gif rename to 美化/QPushButton/按钮进度动画/ScreenShot/按钮字体旋转动画.gif diff --git a/界面美化/QPushButton进度动画/ScreenShot/2.gif b/美化/QPushButton/按钮进度动画/ScreenShot/按钮底部线条动画.gif similarity index 100% rename from 界面美化/QPushButton进度动画/ScreenShot/2.gif rename to 美化/QPushButton/按钮进度动画/ScreenShot/按钮底部线条动画.gif diff --git a/界面美化/QPushButton进度动画/PushButtonFont.py b/美化/QPushButton/按钮进度动画/按钮字体旋转动画.py similarity index 96% rename from 界面美化/QPushButton进度动画/PushButtonFont.py rename to 美化/QPushButton/按钮进度动画/按钮字体旋转动画.py index 8b55fef..7a37651 100644 --- a/界面美化/QPushButton进度动画/PushButtonFont.py +++ b/美化/QPushButton/按钮进度动画/按钮字体旋转动画.py @@ -1,90 +1,90 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年2月1日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: PushButtonFont -@description: -''' - - -import sys - -from PyQt5.QtCore import QPropertyAnimation, Qt, QRectF -from PyQt5.QtGui import QFontDatabase -from PyQt5.QtWidgets import QPushButton, QApplication, QStyleOptionButton,\ - QStylePainter, QStyle - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - - -class PushButtonFont(QPushButton): - - LoadingText = "\uf110" - - def __init__(self, *args, **kwargs): - super(PushButtonFont, self).__init__(*args, **kwargs) - self.fontSize = self.font().pointSize() * 2 - self._rotateAnimationStarted = False - self._rotateAnimation = QPropertyAnimation(self) - self._rotateAnimation.setTargetObject(self) - self._rotateAnimation.setStartValue(1) - self._rotateAnimation.setEndValue(12) - self._rotateAnimation.setDuration(1000) - self._rotateAnimation.setLoopCount(-1) # 无限循环 - self._rotateAnimation.valueChanged.connect(self.update) - self.clicked.connect(self._onClick) - - def paintEvent(self, _): - option = QStyleOptionButton() - self.initStyleOption(option) - painter = QStylePainter(self) - if self._rotateAnimationStarted: - option.text = "" - painter.drawControl(QStyle.CE_PushButton, option) - if not self._rotateAnimationStarted: - return - painter.save() - font = self.font() - font.setPointSize(self.fontSize) - font.setFamily("FontAwesome") - painter.setFont(font) - # 变换坐标为正中间 - painter.translate(self.rect().center()) - # 旋转90度 - painter.rotate(self._rotateAnimation.currentValue() * 30) - fm = self.fontMetrics() - # 在变换坐标后的正中间画文字 - w = fm.width(self.LoadingText) - h = fm.height() - painter.drawText( - QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter, - self.LoadingText) - painter.restore() - - def _onClick(self): - if self._rotateAnimationStarted: - self._rotateAnimationStarted = False - self._rotateAnimation.stop() - return - self._rotateAnimationStarted = True - self._rotateAnimation.start() - - def update(self, _=None): - super(PushButtonFont, self).update() - - -if __name__ == "__main__": - app = QApplication(sys.argv) - # 加载字体到字体库中 - QFontDatabase.addApplicationFont( - "Fonts/FontAwesome/fontawesome-webfont.ttf") - w = PushButtonFont("点击加载") - w.show() - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年2月1日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: PushButtonFont +@description: +''' + + +import sys + +from PyQt5.QtCore import QPropertyAnimation, Qt, QRectF +from PyQt5.QtGui import QFontDatabase +from PyQt5.QtWidgets import QPushButton, QApplication, QStyleOptionButton,\ + QStylePainter, QStyle + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + + +class PushButtonFont(QPushButton): + + LoadingText = "\uf110" + + def __init__(self, *args, **kwargs): + super(PushButtonFont, self).__init__(*args, **kwargs) + self.fontSize = self.font().pointSize() * 2 + self._rotateAnimationStarted = False + self._rotateAnimation = QPropertyAnimation(self) + self._rotateAnimation.setTargetObject(self) + self._rotateAnimation.setStartValue(1) + self._rotateAnimation.setEndValue(12) + self._rotateAnimation.setDuration(1000) + self._rotateAnimation.setLoopCount(-1) # 无限循环 + self._rotateAnimation.valueChanged.connect(self.update) + self.clicked.connect(self._onClick) + + def paintEvent(self, _): + option = QStyleOptionButton() + self.initStyleOption(option) + painter = QStylePainter(self) + if self._rotateAnimationStarted: + option.text = "" + painter.drawControl(QStyle.CE_PushButton, option) + if not self._rotateAnimationStarted: + return + painter.save() + font = self.font() + font.setPointSize(self.fontSize) + font.setFamily("FontAwesome") + painter.setFont(font) + # 变换坐标为正中间 + painter.translate(self.rect().center()) + # 旋转90度 + painter.rotate(self._rotateAnimation.currentValue() * 30) + fm = self.fontMetrics() + # 在变换坐标后的正中间画文字 + w = fm.width(self.LoadingText) + h = fm.height() + painter.drawText( + QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter, + self.LoadingText) + painter.restore() + + def _onClick(self): + if self._rotateAnimationStarted: + self._rotateAnimationStarted = False + self._rotateAnimation.stop() + return + self._rotateAnimationStarted = True + self._rotateAnimation.start() + + def update(self, _=None): + super(PushButtonFont, self).update() + + +if __name__ == "__main__": + app = QApplication(sys.argv) + # 加载字体到字体库中 + QFontDatabase.addApplicationFont( + "Fonts/FontAwesome/fontawesome-webfont.ttf") + w = PushButtonFont("点击加载") + w.show() + sys.exit(app.exec_()) diff --git a/界面美化/QPushButton进度动画/PushButtonLine.py b/美化/QPushButton/按钮进度动画/按钮底部线条动画.py similarity index 96% rename from 界面美化/QPushButton进度动画/PushButtonLine.py rename to 美化/QPushButton/按钮进度动画/按钮底部线条动画.py index 3a17361..58a84bc 100644 --- a/界面美化/QPushButton进度动画/PushButtonLine.py +++ b/美化/QPushButton/按钮进度动画/按钮底部线条动画.py @@ -1,116 +1,116 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年2月1日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: PushButtonLine -@description: -''' -from random import randint -import sys - -from PyQt5.QtCore import QTimer, QThread, pyqtSignal -from PyQt5.QtGui import QPainter, QColor, QPen -from PyQt5.QtWidgets import QPushButton, QApplication, QWidget, QVBoxLayout - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - -StyleSheet = ''' -PushButtonLine { - color: white; - border: none; - min-height: 48px; - background-color: #90caf9; -} -''' - - -class LoadingThread(QThread): - - valueChanged = pyqtSignal(float) # 当前值/最大值 - - def __init__(self, *args, **kwargs): - super(LoadingThread, self).__init__(*args, **kwargs) - self.totalValue = randint(100, 200) # 模拟最大 - - def run(self): - for i in range(self.totalValue + 1): - self.valueChanged.emit(i / self.totalValue) - QThread.msleep(randint(300, 600)) - - -class PushButtonLine(QPushButton): - - lineColor = QColor(0, 150, 136) - - def __init__(self, *args, **kwargs): - self._waitText = kwargs.pop("waitText", "等待中") - super(PushButtonLine, self).__init__(*args, **kwargs) - self._text = self.text() - self._percent = 0 - self._timer = QTimer(self, timeout=self.update) - self.clicked.connect(self.start) - - def paintEvent(self, event): - super(PushButtonLine, self).paintEvent(event) - if not self._timer.isActive(): - return - # 画进度 - painter = QPainter(self) - pen = QPen(self.lineColor) - pen.setWidth(4) - painter.setPen(pen) - painter.drawLine(0, self.height(), self.width() - * self._percent, self.height()) - - def start(self): - if hasattr(self, "loadingThread"): - return self.stop() - self.loadingThread = LoadingThread(self) - self.loadingThread.valueChanged.connect(self.setPercent) - self._timer.start(200) # 200ms - self.loadingThread.start() - self.setText(self._waitText) - - def stop(self): - self.loadingThread.valueChanged.disconnect(self.setPercent) - self.loadingThread.terminate() - self.loadingThread.deleteLater() - del self.loadingThread - self._percent = 0 - self._timer.stop() - self.setText(self._text) - - def setPercent(self, v): - self._percent = v - if v == 1: - self.stop() - self.update() - - def setLineColor(self, color): - self.lineColor = QColor(color) - return self - - -class Window(QWidget): - - def __init__(self, *args, **kwargs): - super(Window, self).__init__(*args, **kwargs) - layout = QVBoxLayout(self) - layout.addWidget(PushButtonLine("点击加载")) - layout.addWidget(PushButtonLine("点击加载").setLineColor("#ef5350")) - layout.addWidget(PushButtonLine("点击加载").setLineColor("#ffc107")) - - -if __name__ == "__main__": - app = QApplication(sys.argv) - app.setStyleSheet(StyleSheet) - w = Window() - w.show() - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年2月1日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: PushButtonLine +@description: +''' +from random import randint +import sys + +from PyQt5.QtCore import QTimer, QThread, pyqtSignal +from PyQt5.QtGui import QPainter, QColor, QPen +from PyQt5.QtWidgets import QPushButton, QApplication, QWidget, QVBoxLayout + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + +StyleSheet = ''' +PushButtonLine { + color: white; + border: none; + min-height: 48px; + background-color: #90caf9; +} +''' + + +class LoadingThread(QThread): + + valueChanged = pyqtSignal(float) # 当前值/最大值 + + def __init__(self, *args, **kwargs): + super(LoadingThread, self).__init__(*args, **kwargs) + self.totalValue = randint(100, 200) # 模拟最大 + + def run(self): + for i in range(self.totalValue + 1): + self.valueChanged.emit(i / self.totalValue) + QThread.msleep(randint(300, 600)) + + +class PushButtonLine(QPushButton): + + lineColor = QColor(0, 150, 136) + + def __init__(self, *args, **kwargs): + self._waitText = kwargs.pop("waitText", "等待中") + super(PushButtonLine, self).__init__(*args, **kwargs) + self._text = self.text() + self._percent = 0 + self._timer = QTimer(self, timeout=self.update) + self.clicked.connect(self.start) + + def paintEvent(self, event): + super(PushButtonLine, self).paintEvent(event) + if not self._timer.isActive(): + return + # 画进度 + painter = QPainter(self) + pen = QPen(self.lineColor) + pen.setWidth(4) + painter.setPen(pen) + painter.drawLine(0, self.height(), self.width() + * self._percent, self.height()) + + def start(self): + if hasattr(self, "loadingThread"): + return self.stop() + self.loadingThread = LoadingThread(self) + self.loadingThread.valueChanged.connect(self.setPercent) + self._timer.start(200) # 200ms + self.loadingThread.start() + self.setText(self._waitText) + + def stop(self): + self.loadingThread.valueChanged.disconnect(self.setPercent) + self.loadingThread.terminate() + self.loadingThread.deleteLater() + del self.loadingThread + self._percent = 0 + self._timer.stop() + self.setText(self._text) + + def setPercent(self, v): + self._percent = v + if v == 1: + self.stop() + self.update() + + def setLineColor(self, color): + self.lineColor = QColor(color) + return self + + +class Window(QWidget): + + def __init__(self, *args, **kwargs): + super(Window, self).__init__(*args, **kwargs) + layout = QVBoxLayout(self) + layout.addWidget(PushButtonLine("点击加载")) + layout.addWidget(PushButtonLine("点击加载").setLineColor("#ef5350")) + layout.addWidget(PushButtonLine("点击加载").setLineColor("#ffc107")) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setStyleSheet(StyleSheet) + w = Window() + w.show() + sys.exit(app.exec_()) diff --git a/界面美化/QScrollBar滚动条样式/README.md b/美化/QScrollBar/README.md similarity index 97% rename from 界面美化/QScrollBar滚动条样式/README.md rename to 美化/QScrollBar/README.md index 0e80c39..408f0e6 100644 --- a/界面美化/QScrollBar滚动条样式/README.md +++ b/美化/QScrollBar/README.md @@ -1,20 +1,20 @@ -# QScrollBar滚动条样式美化 - -### 滚动条分两个方向 - - horizontal 横向 - - vertical 纵向 - -### 简单说明 - - 横向或纵向滚动条整体,也就是(horizontal、vertical) - - 滚动条上面的小滑块(handle) - - 纵向上部、横向左侧区域(sub-page) - - 纵向下部、横向右侧区域(add-page) - - 纵向上部、横向左侧三角形区域(sub-line) - - 纵向下部、横向右侧三角形区域(add-line) - - 纵向上部、横向左侧三角形(up-arrow、left-arrow) - - 纵向下部、横向右侧三角形(down-arrow、right-arrow) - -截图 - -![1](ScreenShot/1.jpg) +# QScrollBar滚动条样式美化 + +### 滚动条分两个方向 + - horizontal 横向 + - vertical 纵向 + +### 简单说明 + - 横向或纵向滚动条整体,也就是(horizontal、vertical) + - 滚动条上面的小滑块(handle) + - 纵向上部、横向左侧区域(sub-page) + - 纵向下部、横向右侧区域(add-page) + - 纵向上部、横向左侧三角形区域(sub-line) + - 纵向下部、横向右侧三角形区域(add-line) + - 纵向上部、横向左侧三角形(up-arrow、left-arrow) + - 纵向下部、横向右侧三角形(down-arrow、right-arrow) + +截图 + +![1](ScreenShot/1.jpg) ![2](ScreenShot/2.jpg) \ No newline at end of file diff --git a/界面美化/QScrollBar滚动条样式/ScreenShot/1.jpg b/美化/QScrollBar/ScreenShot/1.jpg similarity index 100% rename from 界面美化/QScrollBar滚动条样式/ScreenShot/1.jpg rename to 美化/QScrollBar/ScreenShot/1.jpg diff --git a/界面美化/QScrollBar滚动条样式/ScreenShot/2.jpg b/美化/QScrollBar/ScreenShot/2.jpg similarity index 100% rename from 界面美化/QScrollBar滚动条样式/ScreenShot/2.jpg rename to 美化/QScrollBar/ScreenShot/2.jpg diff --git a/界面美化/QScrollBar滚动条样式/ScrollBar.py b/美化/QScrollBar/ScrollBar.py similarity index 96% rename from 界面美化/QScrollBar滚动条样式/ScrollBar.py rename to 美化/QScrollBar/ScrollBar.py index ea0bf2f..2a738c8 100644 --- a/界面美化/QScrollBar滚动条样式/ScrollBar.py +++ b/美化/QScrollBar/ScrollBar.py @@ -1,45 +1,45 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -''' -Created on 2018年1月20日 -@author: Irony."[讽刺] -@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 -@email: 892768447@qq.com -@file: ScrollBar -@description: -''' -from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QTextEdit, QApplication -import chardet - - -__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" -__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" -__Version__ = "Version 1.0" - - -class Window(QTextEdit): - - def __init__(self, parent=None): - super(Window, self).__init__(parent) - # 设置横向纵向滚动条总是显示 - self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - with open("ScrollBar.qss", "rb") as fp: - content = fp.read() - encoding = chardet.detect(content) or {} - content = content.decode(encoding.get("encoding") or "utf-8") - self.setText(content) - # 设置样式 - self.setStyleSheet(content) - - -if __name__ == "__main__": - import sys - app = QApplication(sys.argv) - app.setApplicationName("滚动条样式") - app.setApplicationDisplayName("滚动条样式") - window = Window() - window.show() - sys.exit(app.exec_()) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +Created on 2018年1月20日 +@author: Irony."[讽刺] +@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447 +@email: 892768447@qq.com +@file: ScrollBar +@description: +''' +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QTextEdit, QApplication +import chardet + + +__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com" +__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]" +__Version__ = "Version 1.0" + + +class Window(QTextEdit): + + def __init__(self, parent=None): + super(Window, self).__init__(parent) + # 设置横向纵向滚动条总是显示 + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + with open("ScrollBar.qss", "rb") as fp: + content = fp.read() + encoding = chardet.detect(content) or {} + content = content.decode(encoding.get("encoding") or "utf-8") + self.setText(content) + # 设置样式 + self.setStyleSheet(content) + + +if __name__ == "__main__": + import sys + app = QApplication(sys.argv) + app.setApplicationName("滚动条样式") + app.setApplicationDisplayName("滚动条样式") + window = Window() + window.show() + sys.exit(app.exec_()) diff --git a/界面美化/QScrollBar滚动条样式/ScrollBar.qss b/美化/QScrollBar/ScrollBar.qss similarity index 96% rename from 界面美化/QScrollBar滚动条样式/ScrollBar.qss rename to 美化/QScrollBar/ScrollBar.qss index c9d47c5..5ee4858 100644 --- a/界面美化/QScrollBar滚动条样式/ScrollBar.qss +++ b/美化/QScrollBar/ScrollBar.qss @@ -1,142 +1,142 @@ -/*QScrollBar Style*/ - -/*纵向滚动条*/ -QScrollBar:vertical { - background: transparent; /*背景透明*/ - width: 10px; /*宽度*/ - margin: 0px 0px 0px 0px; /**/ - padding-top: 12px; /*距离上面12px*/ - padding-bottom: 12px; /*距离底部12px*/ -} -/*横向滚动条*/ -QScrollBar:horizontal { - background: transparent; - height: 10px; /*高度*/ - margin: 0px 0px 0px 0px; - padding-left: 12px; /*距离左边12px*/ - padding-right: 12px; /*距离右边12px*/ -} - -/*当鼠标放到纵向或者横向滚动条上面时*/ -QScrollBar:vertical:hover,QScrollBar:horizontal:hover { - background: rgba(0, 0, 0, 30); /*修改背景透明度 30*/ - border-radius: 5px; /*圆角*/ -} - -/*纵向滚动条上面的滑块*/ -QScrollBar::handle:vertical { - background: rgba(0, 0, 0, 50); - width: 10px; - border-radius: 5px; - border: none; -} -/*横向滚动条上面的滑块*/ -QScrollBar::handle:horizontal { - background: rgba(0, 0, 0, 50); - height: 10px; - border-radius: 5px; - border: none; -} - -/*当鼠标放到滚动条滑块上面时改变透明度实现颜色的深浅变化*/ -QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover { - background: rgba(0, 0, 0, 100); -} - -/*纵向滚动条下部分块*/ -QScrollBar::add-page:vertical { - width: 10px; - background: transparent; -} -/*横向滚动条后面部分块*/ -QScrollBar::add-page:horizontal { - height: 10px; - background: transparent; -} -/*纵向滚动条上面部分块*/ -QScrollBar::sub-page:vertical { - width: 10px; - background: transparent; -} -/*横向滚动条左部分块*/ -QScrollBar::sub-page:horizontal { - height: 10px; - background: transparent; -} -/*纵向滚动条顶部三角形位置*/ -QScrollBar::sub-line:vertical { - height: 12px; - width: 10px; - background: transparent; - subcontrol-position: top; -} -/*横向滚动条左侧三角形位置*/ -QScrollBar::sub-line:horizontal { - height: 10px; - width: 12px; - background: transparent; - subcontrol-position: left; -} -/*纵向滚动条向上的三角形小图标*/ -QScrollBar::up-arrow:vertical { - image: url(scrollbar/scrollbar_arrowup_normal.png); -} -/*横向滚动条左边的三角形小图标*/ -QScrollBar::left-arrow:horizontal { - image: url(scrollbar/scrollbar_arrowleft_normal.png); -} -/*纵向滚动条向上的三角形小图标 鼠标悬停*/ -QScrollBar::up-arrow:vertical:hover { - image: url(scrollbar/scrollbar_arrowup_down.png); -} -/*横向滚动条左边的三角形小图标 鼠标悬停*/ -QScrollBar::left-arrow:horizontal:hover { - image: url(scrollbar/scrollbar_arrowleft_down.png); -} -/*纵向滚动条向上的三角形小图标 鼠标按下*/ -QScrollBar::up-arrow:vertical:pressed { - image: url(scrollbar/scrollbar_arrowup_highlight.png); -} -/*横向滚动条左边的三角形小图标 鼠标按下*/ -QScrollBar::left-arrow:horizontal:pressed { - image: url(scrollbar/scrollbar_arrowleft_highlight.png); -} - -/*纵向滚动条下面三角形部分*/ -QScrollBar::add-line:vertical { - height: 12px; - width: 10px; - background: transparent; - subcontrol-position: bottom; -} -/*横向滚动条右边的三角形部分*/ -QScrollBar::add-line:horizontal { - height: 10px; - width: 12px; - background: transparent; - subcontrol-position: right; -} -/*纵向滚动条下面三角形图标*/ -QScrollBar::down-arrow:vertical { - image: url(scrollbar/scrollbar_arrowdown_normal.png); -} -/*横向滚动条右侧三角形图标*/ -QScrollBar::right-arrow:horizontal { - image: url(scrollbar/scrollbar_arrowright_normal.png); -} -/*纵向滚动条下面三角形图标 鼠标悬停*/ -QScrollBar::down-arrow:vertical:hover { - image: url(scrollbar/scrollbar_arrowdown_down.png); -} -/*横向滚动条右侧三角形图标 鼠标悬停*/ -QScrollBar::right-arrow:horizontal:hover { - image: url(scrollbar/scrollbar_arrowright_down.png); -} -/*纵向滚动条下面三角形图标 鼠标按下*/ -QScrollBar::down-arrow:vertical:pressed { - image: url(scrollbar/scrollbar_arrowdown_highlight.png); -} -/*横向滚动条右侧三角形图标 鼠标按下*/ -QScrollBar::right-arrow:horizontal:pressed { - image: url(scrollbar/scrollbar_arrowright_highlight.png); +/*QScrollBar Style*/ + +/*纵向滚动条*/ +QScrollBar:vertical { + background: transparent; /*背景透明*/ + width: 10px; /*宽度*/ + margin: 0px 0px 0px 0px; /**/ + padding-top: 12px; /*距离上面12px*/ + padding-bottom: 12px; /*距离底部12px*/ +} +/*横向滚动条*/ +QScrollBar:horizontal { + background: transparent; + height: 10px; /*高度*/ + margin: 0px 0px 0px 0px; + padding-left: 12px; /*距离左边12px*/ + padding-right: 12px; /*距离右边12px*/ +} + +/*当鼠标放到纵向或者横向滚动条上面时*/ +QScrollBar:vertical:hover,QScrollBar:horizontal:hover { + background: rgba(0, 0, 0, 30); /*修改背景透明度 30*/ + border-radius: 5px; /*圆角*/ +} + +/*纵向滚动条上面的滑块*/ +QScrollBar::handle:vertical { + background: rgba(0, 0, 0, 50); + width: 10px; + border-radius: 5px; + border: none; +} +/*横向滚动条上面的滑块*/ +QScrollBar::handle:horizontal { + background: rgba(0, 0, 0, 50); + height: 10px; + border-radius: 5px; + border: none; +} + +/*当鼠标放到滚动条滑块上面时改变透明度实现颜色的深浅变化*/ +QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover { + background: rgba(0, 0, 0, 100); +} + +/*纵向滚动条下部分块*/ +QScrollBar::add-page:vertical { + width: 10px; + background: transparent; +} +/*横向滚动条后面部分块*/ +QScrollBar::add-page:horizontal { + height: 10px; + background: transparent; +} +/*纵向滚动条上面部分块*/ +QScrollBar::sub-page:vertical { + width: 10px; + background: transparent; +} +/*横向滚动条左部分块*/ +QScrollBar::sub-page:horizontal { + height: 10px; + background: transparent; +} +/*纵向滚动条顶部三角形位置*/ +QScrollBar::sub-line:vertical { + height: 12px; + width: 10px; + background: transparent; + subcontrol-position: top; +} +/*横向滚动条左侧三角形位置*/ +QScrollBar::sub-line:horizontal { + height: 10px; + width: 12px; + background: transparent; + subcontrol-position: left; +} +/*纵向滚动条向上的三角形小图标*/ +QScrollBar::up-arrow:vertical { + image: url(scrollbar/scrollbar_arrowup_normal.png); +} +/*横向滚动条左边的三角形小图标*/ +QScrollBar::left-arrow:horizontal { + image: url(scrollbar/scrollbar_arrowleft_normal.png); +} +/*纵向滚动条向上的三角形小图标 鼠标悬停*/ +QScrollBar::up-arrow:vertical:hover { + image: url(scrollbar/scrollbar_arrowup_down.png); +} +/*横向滚动条左边的三角形小图标 鼠标悬停*/ +QScrollBar::left-arrow:horizontal:hover { + image: url(scrollbar/scrollbar_arrowleft_down.png); +} +/*纵向滚动条向上的三角形小图标 鼠标按下*/ +QScrollBar::up-arrow:vertical:pressed { + image: url(scrollbar/scrollbar_arrowup_highlight.png); +} +/*横向滚动条左边的三角形小图标 鼠标按下*/ +QScrollBar::left-arrow:horizontal:pressed { + image: url(scrollbar/scrollbar_arrowleft_highlight.png); +} + +/*纵向滚动条下面三角形部分*/ +QScrollBar::add-line:vertical { + height: 12px; + width: 10px; + background: transparent; + subcontrol-position: bottom; +} +/*横向滚动条右边的三角形部分*/ +QScrollBar::add-line:horizontal { + height: 10px; + width: 12px; + background: transparent; + subcontrol-position: right; +} +/*纵向滚动条下面三角形图标*/ +QScrollBar::down-arrow:vertical { + image: url(scrollbar/scrollbar_arrowdown_normal.png); +} +/*横向滚动条右侧三角形图标*/ +QScrollBar::right-arrow:horizontal { + image: url(scrollbar/scrollbar_arrowright_normal.png); +} +/*纵向滚动条下面三角形图标 鼠标悬停*/ +QScrollBar::down-arrow:vertical:hover { + image: url(scrollbar/scrollbar_arrowdown_down.png); +} +/*横向滚动条右侧三角形图标 鼠标悬停*/ +QScrollBar::right-arrow:horizontal:hover { + image: url(scrollbar/scrollbar_arrowright_down.png); +} +/*纵向滚动条下面三角形图标 鼠标按下*/ +QScrollBar::down-arrow:vertical:pressed { + image: url(scrollbar/scrollbar_arrowdown_highlight.png); +} +/*横向滚动条右侧三角形图标 鼠标按下*/ +QScrollBar::right-arrow:horizontal:pressed { + image: url(scrollbar/scrollbar_arrowright_highlight.png); } \ No newline at end of file diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowdown_down.png b/美化/QScrollBar/scrollbar/scrollbar_arrowdown_down.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowdown_down.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowdown_down.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowdown_highlight.png b/美化/QScrollBar/scrollbar/scrollbar_arrowdown_highlight.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowdown_highlight.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowdown_highlight.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowdown_normal.png b/美化/QScrollBar/scrollbar/scrollbar_arrowdown_normal.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowdown_normal.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowdown_normal.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowleft_down.png b/美化/QScrollBar/scrollbar/scrollbar_arrowleft_down.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowleft_down.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowleft_down.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowleft_highlight.png b/美化/QScrollBar/scrollbar/scrollbar_arrowleft_highlight.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowleft_highlight.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowleft_highlight.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowleft_normal.png b/美化/QScrollBar/scrollbar/scrollbar_arrowleft_normal.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowleft_normal.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowleft_normal.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowright_down.png b/美化/QScrollBar/scrollbar/scrollbar_arrowright_down.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowright_down.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowright_down.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowright_highlight.png b/美化/QScrollBar/scrollbar/scrollbar_arrowright_highlight.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowright_highlight.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowright_highlight.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowright_normal.png b/美化/QScrollBar/scrollbar/scrollbar_arrowright_normal.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowright_normal.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowright_normal.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowup_down.png b/美化/QScrollBar/scrollbar/scrollbar_arrowup_down.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowup_down.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowup_down.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowup_highlight.png b/美化/QScrollBar/scrollbar/scrollbar_arrowup_highlight.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowup_highlight.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowup_highlight.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowup_normal.png b/美化/QScrollBar/scrollbar/scrollbar_arrowup_normal.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_arrowup_normal.png rename to 美化/QScrollBar/scrollbar/scrollbar_arrowup_normal.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_bar_highlight.png b/美化/QScrollBar/scrollbar/scrollbar_bar_highlight.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_bar_highlight.png rename to 美化/QScrollBar/scrollbar/scrollbar_bar_highlight.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_bar_normal.png b/美化/QScrollBar/scrollbar/scrollbar_bar_normal.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_bar_normal.png rename to 美化/QScrollBar/scrollbar/scrollbar_bar_normal.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_bkg.png b/美化/QScrollBar/scrollbar/scrollbar_bkg.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_bkg.png rename to 美化/QScrollBar/scrollbar/scrollbar_bkg.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_horzbar_down.png b/美化/QScrollBar/scrollbar/scrollbar_horzbar_down.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_horzbar_down.png rename to 美化/QScrollBar/scrollbar/scrollbar_horzbar_down.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_horzbar_highlight.png b/美化/QScrollBar/scrollbar/scrollbar_horzbar_highlight.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_horzbar_highlight.png rename to 美化/QScrollBar/scrollbar/scrollbar_horzbar_highlight.png diff --git a/界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_horzbar_normal.png b/美化/QScrollBar/scrollbar/scrollbar_horzbar_normal.png similarity index 100% rename from 界面美化/QScrollBar滚动条样式/scrollbar/scrollbar_horzbar_normal.png rename to 美化/QScrollBar/scrollbar/scrollbar_horzbar_normal.png diff --git a/界面美化/QSlider美化/PaintQSlider.py b/美化/QSlider/PaintQSlider.py similarity index 100% rename from 界面美化/QSlider美化/PaintQSlider.py rename to 美化/QSlider/PaintQSlider.py diff --git a/界面美化/QSlider美化/QssQSlider.py b/美化/QSlider/QssQSlider.py similarity index 100% rename from 界面美化/QSlider美化/QssQSlider.py rename to 美化/QSlider/QssQSlider.py diff --git a/界面美化/QSlider美化/README.md b/美化/QSlider/README.md similarity index 100% rename from 界面美化/QSlider美化/README.md rename to 美化/QSlider/README.md diff --git a/界面美化/QSlider美化/ScreenShot/1.gif b/美化/QSlider/ScreenShot/1.gif similarity index 100% rename from 界面美化/QSlider美化/ScreenShot/1.gif rename to 美化/QSlider/ScreenShot/1.gif diff --git a/界面美化/QSlider美化/ScreenShot/2.gif b/美化/QSlider/ScreenShot/2.gif similarity index 100% rename from 界面美化/QSlider美化/ScreenShot/2.gif rename to 美化/QSlider/ScreenShot/2.gif diff --git a/美化/README.md b/美化/README.md new file mode 100644 index 0000000..d7dc5eb --- /dev/null +++ b/美化/README.md @@ -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) \ No newline at end of file diff --git a/界面美化/各类进度条/CircleProgressBar.py b/美化/各类进度条/CircleProgressBar.py similarity index 100% rename from 界面美化/各类进度条/CircleProgressBar.py rename to 美化/各类进度条/CircleProgressBar.py diff --git a/界面美化/各类进度条/MetroCircleProgress.py b/美化/各类进度条/MetroCircleProgress.py similarity index 100% rename from 界面美化/各类进度条/MetroCircleProgress.py rename to 美化/各类进度条/MetroCircleProgress.py diff --git a/界面美化/各类进度条/MetroLineProgress.py b/美化/各类进度条/MetroLineProgress.py similarity index 100% rename from 界面美化/各类进度条/MetroLineProgress.py rename to 美化/各类进度条/MetroLineProgress.py diff --git a/界面美化/各类进度条/PercentProgressBar.py b/美化/各类进度条/PercentProgressBar.py similarity index 100% rename from 界面美化/各类进度条/PercentProgressBar.py rename to 美化/各类进度条/PercentProgressBar.py diff --git a/界面美化/各类进度条/README.md b/美化/各类进度条/README.md similarity index 100% rename from 界面美化/各类进度条/README.md rename to 美化/各类进度条/README.md diff --git a/界面美化/各类进度条/ScreenShot/1.gif b/美化/各类进度条/ScreenShot/1.gif similarity index 100% rename from 界面美化/各类进度条/ScreenShot/1.gif rename to 美化/各类进度条/ScreenShot/1.gif diff --git a/界面美化/各类进度条/ScreenShot/2.gif b/美化/各类进度条/ScreenShot/2.gif similarity index 100% rename from 界面美化/各类进度条/ScreenShot/2.gif rename to 美化/各类进度条/ScreenShot/2.gif diff --git a/界面美化/各类进度条/ScreenShot/3.gif b/美化/各类进度条/ScreenShot/3.gif similarity index 100% rename from 界面美化/各类进度条/ScreenShot/3.gif rename to 美化/各类进度条/ScreenShot/3.gif diff --git a/界面美化/水波纹进度条/ProgressBar.py b/美化/水波纹进度条/ProgressBar.py similarity index 100% rename from 界面美化/水波纹进度条/ProgressBar.py rename to 美化/水波纹进度条/ProgressBar.py diff --git a/界面美化/水波纹进度条/README.md b/美化/水波纹进度条/README.md similarity index 96% rename from 界面美化/水波纹进度条/README.md rename to 美化/水波纹进度条/README.md index d63c913..ed35b09 100644 --- a/界面美化/水波纹进度条/README.md +++ b/美化/水波纹进度条/README.md @@ -1,11 +1,11 @@ -# 矩形/圆形 水波纹进度条 - - -### 简单说明 - - 利用正弦函数根据0-width的范围计算y坐标 - - 利用QPainterPath矩形或者圆形作为背景 - - 用QPainterPath把y坐标用lineTo连接起来形成一个U字形+上方波浪的闭合区间 - -截图 - +# 矩形/圆形 水波纹进度条 + + +### 简单说明 + - 利用正弦函数根据0-width的范围计算y坐标 + - 利用QPainterPath矩形或者圆形作为背景 + - 用QPainterPath把y坐标用lineTo连接起来形成一个U字形+上方波浪的闭合区间 + +截图 + ![1](ScreenShot/1.gif) \ No newline at end of file diff --git a/界面美化/水波纹进度条/ScreenShot/1.gif b/美化/水波纹进度条/ScreenShot/1.gif similarity index 100% rename from 界面美化/水波纹进度条/ScreenShot/1.gif rename to 美化/水波纹进度条/ScreenShot/1.gif diff --git a/界面美化/水波纹进度条/TestWidget.py b/美化/水波纹进度条/TestWidget.py similarity index 100% rename from 界面美化/水波纹进度条/TestWidget.py rename to 美化/水波纹进度条/TestWidget.py diff --git a/界面美化/边框动画阴影/1.jpg b/美化/边框动画阴影/1.jpg similarity index 100% rename from 界面美化/边框动画阴影/1.jpg rename to 美化/边框动画阴影/1.jpg diff --git a/界面美化/边框动画阴影/AnimationShadowEffect.py b/美化/边框动画阴影/AnimationShadowEffect.py similarity index 100% rename from 界面美化/边框动画阴影/AnimationShadowEffect.py rename to 美化/边框动画阴影/AnimationShadowEffect.py diff --git a/界面美化/边框动画阴影/README.md b/美化/边框动画阴影/README.md similarity index 100% rename from 界面美化/边框动画阴影/README.md rename to 美化/边框动画阴影/README.md diff --git a/界面美化/边框动画阴影/ScreenShot/1.gif b/美化/边框动画阴影/ScreenShot/1.gif similarity index 100% rename from 界面美化/边框动画阴影/ScreenShot/1.gif rename to 美化/边框动画阴影/ScreenShot/1.gif diff --git a/界面美化/边框动画阴影/Test.py b/美化/边框动画阴影/Test.py similarity index 100% rename from 界面美化/边框动画阴影/Test.py rename to 美化/边框动画阴影/Test.py