tkinter - Change color of a disabled entry widget

眉间皱痕 提交于 2021-01-27 21:50:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!