I would like to destroy the second button by clicking the first
I have also tried "return but2.Destroy() but everything returns an error message.
Can anyone help?
import wx
class DestroyButton(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, "title")
panel = wx.Panel(self)
but1 = wx.Button(panel, label = "click me")
but2 = wx.Button(panel, label = "destroy me")
but1.Bind(wx.EVT_BUTTON, self.destroybut)
vs1 = wx.BoxSizer(wx.VERTICAL)
vs1.Add(but1, 1, flag = wx.EXPAND)
vs1.Add(but2, 1, flag = wx.EXPAND)
panel.SetSizer(vs1)
#but2.Destroy() THIS WORKS
def destroybut(self, event):
QuickSilver.panel.but2.Destroy()
print "button 2 is destroyed"
app = wx.App(0)
frame1 = DestroyButton(parent = None, id = -1).Show()
app.MainLoop()
Thanks.