app crashes when calling self.Close() on wx.Frame

david wrote:

Hi,

Not sure where my problem is, but I can duplicate it with the code
below.
Basically i'm trying to use a single wx.Frame that will have widgets
shared between different wx.panels (things like navigation buttons,
etc).
I'm pretty sure i'm doing something wrong because when I attempt to
close the app via self.Close() in the wx.Frame class, I get a python
exception as the app. closes. The exception is a stack trace so I
didnt include it. But here is the code that causes it - could someone
comment on whether i'm doing this incorrectly? I'm pretty sure it has
to do with how i'm tying in the wx.panel because self.Close() doesnt
crash when I do not add the wx.Panel to the wx.Frame:

    self.SetSizerAndFit(self.parent.vsizer)

Don't do this. Give the panel its own sizer, and in the parent Add() the panel to the parent's sizer like you do for any other widget located on the parent. By setting the panel's sizer to be one that is already used in the parent you are causing the sizer object to be deleted twice when the windows are destroyed.

···

--
Robin Dunn
Software Craftsman