python - 如何动态更改 ttk 按钮字体颜色和背景
问题描述
我尝试了各种方法来做到这一点,但我错过了一些东西。在开始时,我认为我需要创建一种样式并将其分配给按钮
st = ttk.Style()
st.configure('blueTButton', foreground="white", background="blue")
Btn.configure(style='blueTButton')
但我收到一个错误:_tkinter.TclError: Layout blueTButton not found
所以我尝试了这个:
Btn.configure(foreground = 'red')
# and also
Btn.config(foreground = 'red')
以及许多其他愚蠢的尝试。
有人可以帮忙吗?
解决方案
推荐阅读
- php - symfony 4 api 突然变得很慢
- python - 直接打印`float32`和在Python中使用`format()`函数的区别
- android - 领域多类错误打开距离
- jsf - Primefaces DataExporter 只是刷新页面
- unit-testing - Kotlin-mockk 链式调用
- javascript - 将表单数据作为 txt 文件或 json 保存到服务器位置
- json - 如何使用 tsv 中的数组转换 JSON,jq 保持数组结构?
- python - 配置 VSCode 以使用 pip
- c - 为什么查询根服务器时 ns_t_ns 比 ns_t_a 快?
- c# - WPF 自动列出上下文中的项目