diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 5f79d11..8b26c34 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -19,6 +19,14 @@ encoding//\u5B57\u4F53\u6D4B\u8BD5/TestFontRoboto.py=utf-8 encoding//\u68A6\u5E7B\u6811/DreamTree.py=utf-8 encoding//\u6D4F\u89C8\u5668\u83B7\u53D6Cookie/WebEngineView.py=utf-8 encoding//\u6D4F\u89C8\u5668\u83B7\u53D6Cookie/WebView.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//\u7A0B\u5E8F\u91CD\u542F/AutoRestart.py=utf-8 encoding//\u7A97\u53E3\u91CD\u542F/RestartMainWindow.py=utf-8 encoding//\u81EA\u52A8\u66F4\u65B0/mylibs/testlibs.py=utf-8 diff --git a/README.md b/README.md index 1884617..196d38b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ - [1.11 浏览器获取Cookie](浏览器获取Cookie/) - [1.12 全局热键](全局热键/) - [1.13 图片加载](图片加载/) - - [1.4 窗口重启](窗口重启/) + - [1.14 窗口重启](窗口重启/) ### [2.QGraphicsView练习](QGraphicsView练习/) - [2.1 世界地图](QGraphicsView练习/世界地图) @@ -25,4 +25,7 @@ ### [3.PyQtChart练习](PyQtChart练习/) - [3.1 charts](PyQtChart练习/charts) - - [3.2 test](PyQtChart练习/test) \ No newline at end of file + - [3.2 test](PyQtChart练习/test) + +### [4.界面美化](界面美化/) + - [4.1 QMessageBox样式](界面美化/QMessageBox样式) \ No newline at end of file diff --git a/界面美化/QMessageBox样式/README.md b/界面美化/QMessageBox样式/README.md new file mode 100644 index 0000000..2fe5881 --- /dev/null +++ b/界面美化/QMessageBox样式/README.md @@ -0,0 +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();来设置自定义图标 + - 2.3 解决方案一的缺点 \ No newline at end of file diff --git a/界面美化/QMessageBox样式/icons/Abort.png b/界面美化/QMessageBox样式/icons/Abort.png new file mode 100644 index 0000000..3fd6253 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Abort.png differ diff --git a/界面美化/QMessageBox样式/icons/Apply.png b/界面美化/QMessageBox样式/icons/Apply.png new file mode 100644 index 0000000..7a39435 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Apply.png differ diff --git a/界面美化/QMessageBox样式/icons/Cancel.png b/界面美化/QMessageBox样式/icons/Cancel.png new file mode 100644 index 0000000..b29cdcd Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Cancel.png differ diff --git a/界面美化/QMessageBox样式/icons/Close.png b/界面美化/QMessageBox样式/icons/Close.png new file mode 100644 index 0000000..af594a6 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Close.png differ diff --git a/界面美化/QMessageBox样式/icons/Discard.png b/界面美化/QMessageBox样式/icons/Discard.png new file mode 100644 index 0000000..27ee2b0 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Discard.png differ diff --git a/界面美化/QMessageBox样式/icons/Help.png b/界面美化/QMessageBox样式/icons/Help.png new file mode 100644 index 0000000..aea7e14 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Help.png differ diff --git a/界面美化/QMessageBox样式/icons/Ignore.png b/界面美化/QMessageBox样式/icons/Ignore.png new file mode 100644 index 0000000..ab94c83 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Ignore.png differ diff --git a/界面美化/QMessageBox样式/icons/No.png b/界面美化/QMessageBox样式/icons/No.png new file mode 100644 index 0000000..e4a411e Binary files /dev/null and b/界面美化/QMessageBox样式/icons/No.png differ diff --git a/界面美化/QMessageBox样式/icons/NoToAll.png b/界面美化/QMessageBox样式/icons/NoToAll.png new file mode 100644 index 0000000..789bcbf Binary files /dev/null and b/界面美化/QMessageBox样式/icons/NoToAll.png differ diff --git a/界面美化/QMessageBox样式/icons/Ok.png b/界面美化/QMessageBox样式/icons/Ok.png new file mode 100644 index 0000000..e016d07 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Ok.png differ diff --git a/界面美化/QMessageBox样式/icons/Open.png b/界面美化/QMessageBox样式/icons/Open.png new file mode 100644 index 0000000..83cdb75 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Open.png differ diff --git a/界面美化/QMessageBox样式/icons/Reset.png b/界面美化/QMessageBox样式/icons/Reset.png new file mode 100644 index 0000000..084bc41 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Reset.png differ diff --git a/界面美化/QMessageBox样式/icons/RestoreDefaults.png b/界面美化/QMessageBox样式/icons/RestoreDefaults.png new file mode 100644 index 0000000..5b03909 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/RestoreDefaults.png differ diff --git a/界面美化/QMessageBox样式/icons/Retry.png b/界面美化/QMessageBox样式/icons/Retry.png new file mode 100644 index 0000000..5e2bfdb Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Retry.png differ diff --git a/界面美化/QMessageBox样式/icons/Save.png b/界面美化/QMessageBox样式/icons/Save.png new file mode 100644 index 0000000..a464668 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Save.png differ diff --git a/界面美化/QMessageBox样式/icons/SaveAll.png b/界面美化/QMessageBox样式/icons/SaveAll.png new file mode 100644 index 0000000..fc16506 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/SaveAll.png differ diff --git a/界面美化/QMessageBox样式/icons/Yes.png b/界面美化/QMessageBox样式/icons/Yes.png new file mode 100644 index 0000000..af3a669 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/Yes.png differ diff --git a/界面美化/QMessageBox样式/icons/YesToAll.png b/界面美化/QMessageBox样式/icons/YesToAll.png new file mode 100644 index 0000000..643daa5 Binary files /dev/null and b/界面美化/QMessageBox样式/icons/YesToAll.png differ diff --git a/界面美化/QMessageBox样式/方案一/README.md b/界面美化/QMessageBox样式/方案一/README.md new file mode 100644 index 0000000..ec78ff6 --- /dev/null +++ b/界面美化/QMessageBox样式/方案一/README.md @@ -0,0 +1,7 @@ +# 方案一 + +截图 +![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 new file mode 100644 index 0000000..44475d5 Binary files /dev/null and b/界面美化/QMessageBox样式/方案一/ScreenShot/critical.png differ diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/information.png b/界面美化/QMessageBox样式/方案一/ScreenShot/information.png new file mode 100644 index 0000000..87c9fca Binary files /dev/null and b/界面美化/QMessageBox样式/方案一/ScreenShot/information.png differ diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/question.png b/界面美化/QMessageBox样式/方案一/ScreenShot/question.png new file mode 100644 index 0000000..69220e8 Binary files /dev/null and b/界面美化/QMessageBox样式/方案一/ScreenShot/question.png differ diff --git a/界面美化/QMessageBox样式/方案一/ScreenShot/warning.png b/界面美化/QMessageBox样式/方案一/ScreenShot/warning.png new file mode 100644 index 0000000..cc79834 Binary files /dev/null and b/界面美化/QMessageBox样式/方案一/ScreenShot/warning.png differ diff --git a/界面美化/QMessageBox样式/方案一/critical.py b/界面美化/QMessageBox样式/方案一/critical.py new file mode 100644 index 0000000..8f8e0a2 --- /dev/null +++ b/界面美化/QMessageBox样式/方案一/critical.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案一/information.py b/界面美化/QMessageBox样式/方案一/information.py new file mode 100644 index 0000000..f490c80 --- /dev/null +++ b/界面美化/QMessageBox样式/方案一/information.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案一/question.py b/界面美化/QMessageBox样式/方案一/question.py new file mode 100644 index 0000000..6c37319 --- /dev/null +++ b/界面美化/QMessageBox样式/方案一/question.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案一/warning.py b/界面美化/QMessageBox样式/方案一/warning.py new file mode 100644 index 0000000..2dc9723 --- /dev/null +++ b/界面美化/QMessageBox样式/方案一/warning.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案二/README.md b/界面美化/QMessageBox样式/方案二/README.md new file mode 100644 index 0000000..1133397 --- /dev/null +++ b/界面美化/QMessageBox样式/方案二/README.md @@ -0,0 +1,7 @@ +# 方案二 + +截图 +![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 new file mode 100644 index 0000000..506e30b Binary files /dev/null and b/界面美化/QMessageBox样式/方案二/ScreenShot/critical.png differ diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/information.png b/界面美化/QMessageBox样式/方案二/ScreenShot/information.png new file mode 100644 index 0000000..855b529 Binary files /dev/null and b/界面美化/QMessageBox样式/方案二/ScreenShot/information.png differ diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/question.png b/界面美化/QMessageBox样式/方案二/ScreenShot/question.png new file mode 100644 index 0000000..d90fdef Binary files /dev/null and b/界面美化/QMessageBox样式/方案二/ScreenShot/question.png differ diff --git a/界面美化/QMessageBox样式/方案二/ScreenShot/warning.png b/界面美化/QMessageBox样式/方案二/ScreenShot/warning.png new file mode 100644 index 0000000..c68e4f8 Binary files /dev/null and b/界面美化/QMessageBox样式/方案二/ScreenShot/warning.png differ diff --git a/界面美化/QMessageBox样式/方案二/critical.py b/界面美化/QMessageBox样式/方案二/critical.py new file mode 100644 index 0000000..664415d --- /dev/null +++ b/界面美化/QMessageBox样式/方案二/critical.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案二/information.py b/界面美化/QMessageBox样式/方案二/information.py new file mode 100644 index 0000000..40df83e --- /dev/null +++ b/界面美化/QMessageBox样式/方案二/information.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案二/question.py b/界面美化/QMessageBox样式/方案二/question.py new file mode 100644 index 0000000..bd81c43 --- /dev/null +++ b/界面美化/QMessageBox样式/方案二/question.py @@ -0,0 +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() diff --git a/界面美化/QMessageBox样式/方案二/warning.py b/界面美化/QMessageBox样式/方案二/warning.py new file mode 100644 index 0000000..2ea60c7 --- /dev/null +++ b/界面美化/QMessageBox样式/方案二/warning.py @@ -0,0 +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() diff --git a/界面美化/README.md b/界面美化/README.md new file mode 100644 index 0000000..869453d --- /dev/null +++ b/界面美化/README.md @@ -0,0 +1,5 @@ +# 通过QSS或者重绘对界面进行美化 + +### [1.QMessageBox样式](QMessageBox样式/) + - [1.1 方案一](QMessageBox样式/方案一) + - [1.2 方案二](QMessageBox样式/方案二) \ No newline at end of file