Python 为tkinter配置功能
我试图在按下按钮时更改按钮,但使用Python 为tkinter配置功能,python,tkinter,Python,Tkinter,我试图在按下按钮时更改按钮,但使用configure功能时返回错误: A1.config(text="X", state="disabled", relief="SUNKEN") AttributeError: 'NoneType' object has no attribute 'config' 我还尝试使用configure而不是config,响应相同: A1.configure(text="X", state="disabled", relief="SUNKEN") Attrib
configure
功能时返回错误:
A1.config(text="X", state="disabled", relief="SUNKEN")
AttributeError: 'NoneType' object has no attribute 'config'
我还尝试使用configure
而不是config
,响应相同:
A1.configure(text="X", state="disabled", relief="SUNKEN")
AttributeError: 'NoneType' object has no attribute 'configure'
(供参考)
按钮:
A1 = Button(window,text="",width=5, height=1, command=click).place(x=100, y=100)
命令:
def click():
A1.configure(text="X", state="disabled", relief="SUNKEN")
不能定义变量并将其放在同一行中。试试这个:
A1 = Button(window, text="", width=5, height=1)
A1.place(x=100, y=100)
另外,“凹陷”
无效,请执行“凹陷”
或凹陷