在其他功能中使用本地按钮

时间:2017-11-17 03:22:21

标签: python python-2.7 function button tkinter

我有以下代码,问题是我无法在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()

0 个答案:

没有答案