app doesn't terminate after manually closing all frames

When you destroy the child frames, you keep the reference to them.

you have to remove also self.frame[currently_destroyed_window].

so you cycle through self.frames, which don't exist anymore, and
this calls a pydeadobject error.

···

On Tue, 01 Mar 2005 14:09:55 +0100, Christian Kristukat <c.kristukat@hoc.net> wrote:

class AppFrame(wx.Frame):
[...]

    def OnClose(self, evt):
        for i in self.frames:
            if not i.Close():
                evt.Veto()
                return
        self.Destroy()

--
Franz Steinhaeusler

If this is not possible (but that's a bad programming style (?),

you could try:

         for i in self.frames:
             if i:
                 if not i.Close():
                     evt.Veto()
                     return

or what I found in archive from Mike C. Fletcher:

    try:
       frame.Close( False )
    except wx.PyDeadObjectError:
       pass # it's already gone away anyway, no need to close

···

On Tue, 01 Mar 2005 14:58:20 +0100, Franz Steinhäusler <franz.steinhaeusler@gmx.at> wrote:

On Tue, 01 Mar 2005 14:09:55 +0100, Christian Kristukat ><c.kristukat@hoc.net> wrote:

class AppFrame(wx.Frame):
[...]

    def OnClose(self, evt):
        for i in self.frames:
            if not i.Close():
                evt.Veto()
                return
        self.Destroy()

When you destroy the child frames, you keep the reference to them.

you have to remove also self.frame[currently_destroyed_window].

--
Franz Steinhaeusler

(the break in OnClose of class Frame is wrong (there is no loop)).

Maybe this is an issue with GTK2 (?).
On my machine (WinXP), wxPython Version: 2.5.4.1pre.20050226, Python
2.4, it works well, whatever I close first, or I say "no, don't close".

···

On Tue, 01 Mar 2005 15:56:16 +0100, Christian Kristukat <ckkart@hoc.net> wrote:

Thanks a lot for your help, but your proposal still doesn't work. The problem is
that you cycle through the original frames list in AppFrame.OnClose which is
modified by the childs' OnClose. I changed AppFrame.OnClose again and I'm back
at my old problem... see below.

--
Franz Steinhaeusler

Franz Steinhäusler wrote:

Maybe this is an issue with GTK2 (?).
On my machine (WinXP), wxPython Version: 2.5.4.1pre.20050226, Python
2.4, it works well, whatever I close first, or I say "no, don't close".

Because on MSW the wxMessageDialog is not really a wxDialog, but rather a wrapper around a API function.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!