python|PyQt5 界面美化之 一键换风格(再也不用一个个调颜色啦~)
前言 【python|PyQt5 界面美化之 一键换风格(再也不用一个个调颜色啦~)】pyqt5 搭建界面很快,但是嘞,往往都不好看,所以需要美化,之前查了好久终于找到一个好用又好看的!!!!要不然还得苦哈哈的调配色,话不多说,看示例~
1、依赖模块
pip3 install QCandyUi
2、使用方法 仅需在需要美化的窗口类上加上@colorful装饰器即可
也可以调用CandyWindow.creatWindow()返回经美化的QWidget (推荐用这种)
3、示例 化妆前
class MainWindow(QMainWindow, Ui_MainWindow):.......if __name__ == '__main__':app = QApplication(sys.argv)
ui = MainWindow()
ui.show()
sys.exit(app.exec_())
文章图片
化了淡淡的深蓝妆(仅加了@colorful)
from QCandyUi.CandyWindow import colorful@colorful('blueDeep')class MainWindow(QMainWindow, Ui_MainWindow):.......if __name__ == '__main__':app = QApplication(sys.argv)
ui = MainWindow()
ui.show()
sys.exit(app.exec_())
文章图片
- 另一种化妆方式(使用CandyWindow.createWindow)
if __name__ == '__main__':app = QApplication(sys.argv)
ui = MainWindow()
ui = CandyWindow.createWindow(ui, 'blue')
ui.show()
# demo =MsgBox(
# demo.show()
sys.exit(app.exec_())
文章图片
PS:
想自己新增颜色主题可以在theme.json里面配, 按照theme.json里的格式配即可
暂时默认提供的配色有blue, blueGreen, pink,都是类似糖果一样的颜色,个人感觉有点太亮了,不过比一个个按钮调颜色方便多了~~
py模块的安装包在…\site-packages\QCandyUi\candyUi
例如,现有配色:
{"theme":"",
"blueGreen": {"fontLight": "#FFFFFF",
"fontDark": "#015F5F",
"normal": "#33CCCC",
"light": "#ECFEFE",
"deep": "#28AAAA",
"disLight": "#CCCCCC",
"disDark": "#999999"
},
"blueDeep": {"fontLight": "#FFFFFF",
"fontDark": "#192e4b",
"normal": "#4c73a8",
"light": "#88b5f1",
"deep": "#2e486c",
"disLight": "#CCCCCC",
"disDark": "#999999"
},
"pink": {"fontLight": "#FFFFFF",
"fontDark": "#bd158c",
"normal": "#f7a5f0",
"light": "#fbc2f6",
"deep": "#fbaaf4",
"disLight": "#CCCCCC",
"disDark": "#999999"
},
"blue": {"fontLight": "#FFFFFF",
"fontDark": "#006a91",
"normal": "#00aeed",
"light": "#80ddfe",
"deep": "#00aeed",
"disLight": "#CCCCCC",
"disDark": "#999999"
}
}
推荐阅读
- python学习之|python学习之 实现QQ自动发送消息
- 逻辑回归的理解与python示例
- python自定义封装带颜色的logging模块
- 【Leetcode/Python】001-Two|【Leetcode/Python】001-Two Sum
- Python基础|Python基础 - 练习1
- Python爬虫|Python爬虫 --- 1.4 正则表达式(re库)
- Python(pathlib模块)
- python青少年编程比赛_第十一届蓝桥杯大赛青少年创意编程组比赛细则
- Python数据分析(一)(Matplotlib使用)
- Python|Python 9.20