【发布时间】:2019-11-21 03:02:38
【问题描述】:
有没有办法可以在 python 中更改禁用条目小部件的颜色?
x = tk.Entry(parent)
x.configure({"background": "gray24"})
x.configure({"fg": "white"})
x.configure({"state": "disable"})
上面的代码仅在小部件的“状态”为“正常”时才有效。
【问题讨论】:
有没有办法可以在 python 中更改禁用条目小部件的颜色?
x = tk.Entry(parent)
x.configure({"background": "gray24"})
x.configure({"fg": "white"})
x.configure({"state": "disable"})
上面的代码仅在小部件的“状态”为“正常”时才有效。
【问题讨论】:
设置入口小部件的disabledbackground 属性。
x.configure({"disabledbackground": "newcolour"})
其中"newcolour" 是您希望在禁用条目小部件时看到的颜色。您也可以使用disabledforeground 来表示前景色,而不是背景色。
【讨论】: