【问题标题】:tkinter - Change color of a disabled entry widgettkinter - 更改禁用条目小部件的颜色
【发布时间】:2019-11-21 03:02:38
【问题描述】:

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

x = tk.Entry(parent)
x.configure({"background": "gray24"})
x.configure({"fg": "white"})
x.configure({"state": "disable"})

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

【问题讨论】:

    标签: python tkinter widget


    【解决方案1】:

    设置入口小部件的disabledbackground 属性。

    x.configure({"disabledbackground": "newcolour"})
    

    其中"newcolour" 是您希望在禁用条目小部件时看到的颜色。您也可以使用disabledforeground 来表示前景色,而不是背景色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-21
      • 2023-02-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-23
      • 2012-11-15
      • 2018-05-15
      相关资源
      最近更新 更多