2
在我的程序中,我在按钮中使用图片。如果我现在用button.configure(state="disabled")
禁用此按钮,我会在整个按钮上覆盖一层白色。我可以删除此覆盖吗?如果是的话如何?提前致谢。下面是一个例子代码:Python Tkinter删除禁用的按钮覆盖
import Tkinter as tk
window = tk.Tk()
def disable():
button1.config(state="disabled")
button1=tk.Button(command=disable)
testbild=tk.PhotoImage(file="testbild.gif")
button1.image=testbild
button1.configure(relief="flat", image=testbild, height=180, width=180,
background="lightgreen", activebackground="lightgreen", bd=0)
button1.pack()
window.mainloop()
我认为这是Tkinter的中不可避免的一个方面。有人在这个问题[这里](http://stackoverflow.com/questions/11366349/tkinter-color-of-disabled-buttons-disabled-optionmenus)提出了一个解决方法,你可以尝试。 – Ajean 2014-12-04 20:54:00
您有使用按钮的原因吗?如果你想要一个图像在用户点击时不做任何事情,只需将图像添加到标签。禁用的效果是为了达到目的,提醒用户他们无法做到他们期望能够做的事情。 – 2014-12-04 20:56:24