【发布时间】:2015-02-02 20:45:02
【问题描述】:
在我的程序中,我在按钮中使用图片。如果我现在用button.configure(state="disabled") 禁用这个按钮,我会在整个按钮上得到一个白色的覆盖层。我可以删除此叠加层吗?如果是怎么办?提前致谢。这是一个示例代码:
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 一个不可避免的方面。有人在这个问题here 建议了一个你可以尝试的解决方法。
-
您使用按钮有什么原因吗?如果您想要在用户单击时不执行任何操作的图像,只需将图像添加到标签。禁用效果是有目的的,提醒用户他们不能做他们期望能够做的事情。
标签: python python-2.7 button tkinter overlay