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_())    

PyQt5 界面美化之 一键换风格(再也不用一个个调颜色啦~)_第1张图片

化了淡淡的深蓝妆(仅加了@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_())   

PyQt5 界面美化之 一键换风格(再也不用一个个调颜色啦~)_第2张图片

  • 另一种化妆方式(使用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_())

PyQt5 界面美化之 一键换风格(再也不用一个个调颜色啦~)_第3张图片

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)