2
我是Python的新手,我試圖使用Tkinter創建一個簡單的應用程序。在Tkinter中單擊後禁用按鈕
def appear(x):
return lambda: results.insert(END, x)
letters=["A", "T", "D", "M", "E", "A", "S", "R", "M"]
for index in range(9):
n=letters[index]
nButton = Button(buttons, bg="White", text=n, width=5, height=1,
command =appear(n), relief=GROOVE).grid(padx=2, pady=2, row=index%3,
column=index/3)
我想要做的就是禁用按鈕,一旦我點擊它們。 我試圖
def appear(x):
nButton.config(state="disabled")
return lambda: results.insert(END, x)
但它給我下面的錯誤:
NameError: global name 'nButton' is not defined