wx.Notebook problem under win2k

Hello everyone,

I’m having an unusual problem with wx.Notebook
under windows 2000. My application crashes any time it is started up with
only one page in the notebook that is on its main window. It crashes without
throwing an exception, the application just closes and the message “Python.exe
has generated errors and will be closed” is displayed. I’ve traced
this through in the debugger, and it appears that when a notebook containing
only one page is added to a sizer, and then SetSizerAndFit is called from
a panel with that sizer as its argument, the interpreter crashes. This
code runs correctly under Windows XP, the error appears to only occur under
Windows 2000. Here’s some sample code:

import wx

app = wx.PySimpleApp()

frame = wx.Frame(None)

panel = wx.Panel(frame, -1)

sizer = wx.BoxSizer(wx.VERTICAL)

nb = wx.Notebook(frame, -1, style=wx.NB_MULTILINE

wx.NB_NOPAGETHEME)

panel2 = wx.Panel(nb, -1)

panel3 = wx.Panel(nb, -1)

nb.AddPage(panel2, “Page 1”)

#nb.AddPage(panel3, “Page 2”)
#Uncomment this line and it works, comment it out and it crashes

sizer.Add(nb)

panel.SetSizerAndFit(sizer) #Crashes
here

Any ideas? Is this a real bug, or am
I doing something wrong?

Thanks,

–Matt

This is caused by creating your notebook as a child of frame, but adding
it to panel's sizer. Fixing that bit no longer crashes Python on the
SetSizerAndFit call.

- Josiah

···

Matthew J Harriger <mharriger@unmc.edu> wrote:

I'm having an unusual problem with wx.Notebook under windows 2000. My
application crashes any time it is started up with only one page in the
notebook that is on its main window. It crashes without throwing an
exception, the application just closes and the message "Python.exe has
generated errors and will be closed" is displayed. I've traced this
through in the debugger, and it appears that when a notebook containing
only one page is added to a sizer, and then SetSizerAndFit is called from
a panel with that sizer as its argument, the interpreter crashes. This
code runs correctly under Windows XP, the error appears to only occur
under Windows 2000. Here's some sample code:

nb = wx.Notebook(frame, -1, style=wx.NB_MULTILINE | wx.NB_NOPAGETHEME)
sizer.Add(nb)

Thanks Josiah, that is an error that
I didn’t notice, however, I’m still having problems. I tried changing

`nb = wx.Notebook(frame, -1, style=wx.NB_MULTILINE

wx.NB_NOPAGETHEME)`

to

`nb = wx.Notebook(panel, -1, style=wx.NB_MULTILINE

wx.NB_NOPAGETHEME)`

but python still crashes for me. Other ideas?

--Matt

Josiah Carlson jcarlson@uci.edu
05/18/2006 11:48 AM

To

Matthew J Harriger mharriger@unmc.edu,
wxPython-users@lists.wxwidgets.org
cc

Subject

Re: [wxPython-users] wx.Notebook problem
under win2k

`

I’m having an unusual problem with wx.Notebook under windows 2000.
My

application crashes any time it is started up with only one page in
the

notebook that is on its main window. It crashes without throwing an

exception, the application just closes and the message "Python.exe
has

generated errors and will be closed" is displayed. I’ve traced
this

through in the debugger, and it appears that when a notebook containing

only one page is added to a sizer, and then SetSizerAndFit is called
from

a panel with that sizer as its argument, the interpreter crashes.
This

code runs correctly under Windows XP, the error appears to only occur

under Windows 2000. Here’s some sample code:

nb = wx.Notebook(frame, -1, style=wx.NB_MULTILINE | wx.NB_NOPAGETHEME)

sizer.Add(nb)

This is caused by creating your notebook as a child of frame, but adding

it to panel’s sizer. Fixing that bit no longer crashes Python on
the

SetSizerAndFit call.

  • Josiah

`

···

Matthew J Harriger mharriger@unmc.edu wrote:

Getting rid of the wx.NB_MULTILINE flag fixes the crash on my win2k
machine.

- Josiah

···

Matthew J Harriger <mharriger@unmc.edu> wrote:

Thanks Josiah, that is an error that I didn't notice, however, I'm still
having problems. I tried changing

nb = wx.Notebook(frame, -1, style=wx.NB_MULTILINE | wx.NB_NOPAGETHEME)

to

nb = wx.Notebook(panel, -1, style=wx.NB_MULTILINE | wx.NB_NOPAGETHEME)

but python still crashes for me. Other ideas?