问题
Is there a way that I could change a color of disabled entry widget in python?
x = tk.Entry(parent)
x.configure({"background": "gray24"})
x.configure({"fg": "white"})
x.configure({"state": "disable"})
The code above only works when the "state" of the widget is "normal".
回答1:
Set the entry widget's disabledbackground
attribute.
x.configure({"disabledbackground": "newcolour"})
Where "newcolour"
is the colour you want to see when the entry widget is disabled. You can also use disabledforeground
for foreground colours, rather than background colours.
来源:https://stackoverflow.com/questions/58966640/tkinter-change-color-of-a-disabled-entry-widget