Sample attached. This sample crashes when I call DeleteAllPages() on the button click.
Here is the code for reference:
···
#----------------------------------------------------------------------------
class MainFrame(wx.Frame):
“”""""
#----------------------------------------------------------------------
def init(self):
“”“Constructor”""
wx.Frame.init(self, None, title=“Generic Notebook”, size=(800,600))
bSizer = wx.BoxSizer(wx.HORIZONTAL)
self.testNotebook = wx.Notebook(self)
nbPanel = wx.Window(self.testNotebook)
self.testNotebook.AddPage(nbPanel, “test1”)
self.testNotebook.AddPage(nbPanel, “test2”)
self.testNotebook.AddPage(nbPanel, “test3”)
deleteButton = wx.Button(self, label=“delete all then add page”)
deleteButton.Bind(wx.EVT_BUTTON, self.DeletePages)
bSizer.Add(deleteButton,0,0)
bSizer.Add(self.testNotebook,1,wx.EXPAND,10)
self.SetSizer(bSizer)
self.Show()
return
def DeletePages(self, event):
self.testNotebook.DeleteAllPages()
otherPanel = wx.Window(self.testNotebook)
self.testNotebook.AddPage(otherPanel, “NewPanel”)
return
if name == “main”:
app = wx.App(False)
frame = MainFrame()
app.MainLoop()
On Wednesday, April 26, 2017 at 9:57:29 AM UTC-6, Robin Dunn wrote:
On Wednesday, April 26, 2017 at 8:29:03 AM UTC-7, PyMapper Developer wrote:
I’m in the same thread, and not calling from EVT_PAINT. I tried wx.CallAfter, but it returned the same errors.
Please create a small runnable sample that demonstrates the problem.
–
Robin Dunn
Software Craftsman
http://wxPython.org