Re: wxNotebook and DeleteAllPages()
PyMapper Developer <[email protected]>
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
Sample attached. This sample crashes when I call DeleteAllPages() on the
button click.
Here is the code for reference:
import sys
import wx
#----------------------------------------------------------------------------
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
>
>
--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
notebook_test.py
(text/x-python, 1.1 KB)
import sys
import wx
#----------------------------------------------------------------------------
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()