tkinter - 更改禁用条目小部件的颜色

Vii*_*iin 2 python tkinter widget

有没有办法可以改变 python 中禁用条目小部件的颜色?

x = tk.Entry(parent)
x.configure({"background": "gray24"})
x.configure({"fg": "white"})
x.configure({"state": "disable"})
Run Code Online (Sandbox Code Playgroud)

上面的代码仅在小部件的“状态”为“正常”时才有效。

小智 5

设置条目小部件的disabledbackground属性。

x.configure({"disabledbackground": "newcolour"})
Run Code Online (Sandbox Code Playgroud)

"newcolour"禁用条目小部件时您希望看到的颜色在哪里。您还可以使用disabledforeground前景色,而不是背景色。