我有以下代码,问题是我无法在Marca3
中使用在Marca2
中创建按钮,因此我无法将其删除。我认为那是因为没有在同一个函数中创建使用。
设置对象C1已经创建
代码:
#The error says 'AttributeError: 'NoneType' object has no attribute 'destroy''
import Tkinter
den = tkinter.Tk()
def Marca2(b):
if b == 1:
C1.destroy()
J1 = Button(MenuP, text = "J1",command = lambda: Definir(1,0)).place(x = 100,y = 100) #Here is created the button
def Marca3(b):
if b == 1:
J1.destroy() #Here is where i use that button
C1 = Button(MenuP, text = "1",command = lambda: Definir(1,0)).place(x = 100,y = 100)
Marca2(1)
Marca3(1)
den.mainloop()