Find why program does not exit after frame is destroyed

92 views
Skip to first unread message

AlexTZ

unread,
Oct 16, 2010, 7:24:44 AM10/16/10
to wxPython-users
I gather that a wxPython program will not exit if some window (or
other resource?) must be Destroy()'d but has not been.

How can I find what that window/resource is?

More generally, does anyone know how to debug a wxPython program that
does not exit after the main window goes away - occasionally?

Boštjan Mejak

unread,
Oct 16, 2010, 3:50:30 PM10/16/10
to wxpytho...@googlegroups.com
For example, if you create a traybar icon using the misfortunately named class wx.TaskBarIcon(), you must explicitly Destroy() that instance of wx.TaskBarIcon() at application exit, otherwise you would see the same effect you are seeing in your application. You must have forget to Destroy() some object that keeps wxPython's main application object alive and kicking.


Boštjan Mejak

unread,
Oct 16, 2010, 3:51:54 PM10/16/10
to wxpytho...@googlegroups.com
Oh yes, you were asking about how to find that window/resource. I hope Robin Dunn will answer that one, too. ;)  I am interested in the answer as well.

Robin Dunn

unread,
Oct 16, 2010, 6:48:26 PM10/16/10
to wxpytho...@googlegroups.com


You can use the WIT to get a look at what windows still exist when you
don't expect them to. Or you can just use wx.GetTopLevelWindowList()
and see what is in the list.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Boštjan Mejak

unread,
Oct 16, 2010, 8:26:38 PM10/16/10
to wxpytho...@googlegroups.com
Robin, please tell us in what way and where in the application can we use the wx.GetTopLevelWindowList().

>>> import wx
>>> wx.GetTopLevelWindowList()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'GetTopLevelWindowList'


cappy2112

unread,
Oct 16, 2010, 9:56:14 PM10/16/10
to wxPython-users
Try this

import wx
wx.GetTopLevelWindows()
> > To unsubscribe, send email to wxPython-user...@googlegroups.com<wxPython-users%2Bunsu...@googlegroups.com>
> > or visithttp://groups.google.com/group/wxPython-users?hl=en
>
>

Boštjan Mejak

unread,
Oct 17, 2010, 2:27:42 AM10/17/10
to wxpytho...@googlegroups.com
Ah, yes, this wx.GetTopLevelWindows() works. Thank you.


Ray Pasco

unread,
Oct 17, 2010, 2:54:11 PM10/17/10
to Wxpython Users
wx.Exit() will always force an exit, no matter what, but it may also bypass any wx.EVT_CLOSE handlers you may have added. Also, it does not "exit...the application". It exits the wxPython app.MainLoop(). Whether or not the Python interpreter is also exited is up to what code you have put after the app.MainLoop() statement.

Package wx

"Exit()

Force an exit of the [sic] application. Convenience for wx.GetApp().Exit()"


C M

unread,
Oct 17, 2010, 3:49:18 PM10/17/10
to wxpytho...@googlegroups.com
Ray, your comment is not in the thread--again. Did you really click
on "reply" to the previous message?

Boštjan Mejak

unread,
Oct 17, 2010, 4:38:46 PM10/17/10
to wxpytho...@googlegroups.com
There's also wx.App.ExitMainLoop() which destroys the wxPython's application object. Not sure if it kills Python application object, too.

On Sun, Oct 17, 2010 at 9:49 PM, C M <cmpy...@gmail.com> wrote:
Ray, your comment is not in the thread--again.  Did you really click
on "reply" to the previous message?

Ray Pasco

unread,
Oct 18, 2010, 10:59:52 AM10/18/10
to wxPython-users
On Oct 17, 3:49 pm, C M <cmpyt...@gmail.com> wrote:
> Ray, your comment is not in the thread--again.  Did you really click
> on "reply" to the previous message?

Yes, I really did click the [Reply] button this time to reply.

My only guess is that the Firefox browsers I've used (the latest
versions) to send Gmail is somehow messing things up. Firefox has been
self-updating many times in the last few months. I'm currently using
3.6.10.??.??.??

(This reply was sent using Firefox. I will resend using MS IE as an
experiment.)

Ray Pasco

unread,
Oct 18, 2010, 11:21:59 AM10/18/10
to Wxpython Users
This reply is being made using Google Gmail in the MS IE browser to determine whether or not this reply is correctly added to the thread indicated in the email's Subject line or incorrectly creates a new thread.
------------------------------------------------------------------------------------------------------------------
 
Re: "Find why program does not exit after frame is destroyed "
 
On Oct 17, 3:49 pm, C M <cmpyt...@gmail.com> wrote:
> Ray, your comment is not in the thread--again.  Did you really click
> on "reply" to the previous message?
 
Yes, I really did click the [Reply] button to reply.
 
My only guess is that the Firefox browsers I've used (the latest versions) to send Gmail is somehow messing things up. Firefox has been self-updating many times in the last few months. I'm currently using 3.6.10.??.??.?? [on Win7].
Reply all
Reply to author
Forward
0 new messages