Why my application doesn't exit even frame.Destroy()?

I call self.Destroy() at main frame's menu event handler. But I found
sometimes, program will still exist.

My code is very simple:

        if self.tbicon is not None:
            self.tbicon.Destroy()
        self.Destroy()

Should I call wx.Exit() to force program exit?
Thanks.

···


View this message in context: http://www.nabble.com/Why-my-application-doesn't-exit-even-frame.Destroy()--tp20027484p20027484.html
Sent from the wxPython-users mailing list archive at Nabble.com.

blp330 wrote:

I call self.Destroy() at main frame's menu event handler. But I found
sometimes, program will still exist.

My code is very simple:

        if self.tbicon is not None:
            self.tbicon.Destroy()
        self.Destroy()

Should I call wx.Exit() to force program exit?
Thanks.

I found the reason, it is because I have a modal dialog showed. I call event
handler from taskbar icon's menu, then the application won't exit. I think
this is because the dialog is still alive.

But... how can I prevent this situation? check wx.ActiveWindow() before call
self.Destroy() ???

Thanks.

···

--
View this message in context: http://www.nabble.com/Why-my-application-doesn't-exit-even-frame.Destroy()--tp20027484p20027680.html
Sent from the wxPython-users mailing list archive at Nabble.com.

blp330 wrote:

blp330 wrote:

I call self.Destroy() at main frame's menu event handler. But I found
sometimes, program will still exist.

My code is very simple:

        if self.tbicon is not None:
            self.tbicon.Destroy()
        self.Destroy()

Should I call wx.Exit() to force program exit? Thanks.

I found the reason, it is because I have a modal dialog showed. I call event
handler from taskbar icon's menu, then the application won't exit. I think
this is because the dialog is still alive.

But... how can I prevent this situation? check wx.ActiveWindow() before call
self.Destroy() ???

Or set some flag that can be checked before showing the taskbar icon's menu, and then use that flag to disable that menu item while the dialog is active. This way you'll never get as far as calling the Destroy because the user will not be able to choose the menu item.

Or if you don't like that then you can get the list of top level windows with wx.GetTopLevelWindows() and just close them all.

···

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