【发布时间】:2015-12-28 13:23:19
【问题描述】:
我有一个处于“禁用”状态的 ttk 条目。 禁用时输入字段的背景颜色为浅蓝色。 如何将其更改为默认的灰色?从这篇文章中,我了解了如何更改前景色。 tkinter ttk Entry widget -disabledforeground
我尝试了相同的背景颜色方法,但没有成功。 我在 Windows 7 中使用 python 2.7。
这是我根据上述帖子尝试的代码:
from Tkinter import *
from ttk import *
root=Tk()
style=Style()
style.map("TEntry",background=[("active", "black"), ("disabled", "red")])
entry_var=StringVar()
entry=Entry(root,textvariable=entry_var,state='disabled')
entry.pack()
entry_var.set('test')
root.mainloop()
【问题讨论】: