I have the code below and the exact same code works when its put outside the function but does not when its called as a function, and it seems the function is being called correctly because the print line works
import wx
class DestroyButton(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, "title")
self.but1 = wx.Button(self, label = "click me")
self.but2 = wx.Button(self, label = "destroy me")
self.but1.Bind(wx.EVT_BUTTON, self.destroybut)
self.vs1 = wx.BoxSizer(wx.VERTICAL)
self.vs1.Add(self.but1, 1, flag = wx.EXPAND)
self.vs1.Add(self.but2, 1, flag = wx.EXPAND)
self.SetSizer(self.vs1)
#self.vs1.Remove(self.but2)
#self.SetSizer(self.vs1)
def destroybut(self, event):
print "button 2 is destroyed"
self.vs1.Remove(self.but2)
self.SetSizer(self.vs1)
app = wx.App(0)
frame1 = DestroyButton(parent = None, id = -1).Show()
app.MainLoop()
any advice?