Tkinter 界面美化-- ttkbootstrap

用tkinter写的gui,为了使界面美化,从而引入 ttkbootstrap

前期准备

先上效果图(这只是其中一个 主题的结果)
在这里插入图片描述
主题还有

light
cosmo - flatly - journal - literal - lumen - minty - pulse - sandstone - united - yeti

dark
cyborg - darkly - solar - superhero

预览

python -m ttkbootstrap

可以查看每个主题的效果。

如果没有找到合适的主题 ,还可以自己创建(官方有心了)

python -m ttkcreator

在这里插入图片描述
此外致敬官方!(官方文档

安装

pip install ttkbootstrap

使用

from ttkbootstrap import Style
from tkinter import ttk

style = Style(theme = "cosmo") # 使用的主题名称

window = style.master
window.geometry("300x200")

ttk.Button(window, text="Submit", style='primary.TButton').pack(side='left', padx=5, pady=10)
ttk.Button(window, text="Submit", style='success.Outline.TButton').pack(side='left', padx=5, pady=10)
window.mainloop()

效果图:
在这里插入图片描述

pyinstaller 打包

如果如果直接打包的话,很可能会出现报错

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\_MEI132882\\ttkbootstrap\\themes.json'
[7632] Failed to execute script 'main' due to unhandled exception!

经过在网上的“无限遨游”,终于找到方法
打包时加上

--collect-all ttkbootstrap

例如

pyinstaller Test.py  -F  -w  --collect-all ttkbootstrap

此处致敬 https://github.com/israel-dryer/ttkbootstrap/issues/43

  • 33
    点赞
  • 272
    收藏
    觉得还不错? 一键收藏
  • 22
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值