WxPython won't close Frame with a parent who is a window handle?

I wonder if your Close call may be hanging in the close-handler. Have you tried calling Destroy instead? If that doesn't help, then the only solution would seem to be "reparenting" or "detaching" your frame -- I don't see a way to do that in wx but maybe you could drop down to win32 API for that one task...?

I wonder if your Close call may be hanging in the close-handler. Have you tried calling Destroy instead? If that doesn't help, then the only solution would seem to be "reparenting" or "detaching" your frame -- I don't see a way to do that in wx, but maybe you could drop down to win32 API for that one task...?

I've tried both close and destroy. I'm not sure I understand what you mean by "Dropping down to win32 API", could you elaborate? – Fry Jun 2 '09 at 20:18 I mean, for example, getting the HWND of the frame and trying to destroy it via DestroyWindow(hFrame); setting WM_EX_NOPARENTNOTIFY at window creation to make sure the "pseudo"-parent doesn't get involved in the destruction/closing process; and other low-level tricks that Win32 makes available but may not be surfaced by cross-platform frameworks such as wx -- see msdn.microsoft.Com/en-us/library/aa383749(VS.85).

Aspx for many more details. – Alex Martelli Jun 2 '09 at 20:28 I can't seem to find a way to implement your suggestions in Python. Right now I've just set the handle window to be destroyed on the Python program's exit.

I can't seem to find any more info anywhere else – Fry Jun 2 '09 at 21:53 Sorry, I shouldn't have taken this for granted -- to play with the win32 APIs from Python, you can use the standard library module ctypes (search for cypes win32 for examples, docs &c) or the extension package 'win32all' (search for win32all for docs, downloads &c). – Alex Martelli Jun 2 '09 at 1:31.

If reparenting is all you need, you can try frame. Reparent(None) before frame.Close().

Thanks, but reparenting doesn't work. The earliest I know that the form is closing is in the OnClose event, which reparenting there seems to have no effect – Fry Jun 5 '09 at 18:03.

My resolution to this is a little bit hacked, and admittedly not the most elegant solution that I've ever come up with - but it works rather effectively... Basically my steps are to start a thread that polls to see whether the window handle is existent or not. While it's still existent, do nothing. If it no longer exists, kill the python application, allowing the handle (and main application) to be released.

Class CheckingThread(threading. Thread): ''' This class runs a check on Parent Window to see if it still is running If Parent Window closes, this class kills the Python Window application in memory ''' def run(self): ''' Checks Parent Window in 5 seconds intervals to make sure it is still alive. If not alive, exit application ''' self.

NeedKill = False while not self. NeedKill: if self. Handle is not None: if not win32gui.

IsWindow(self. Handle): os. _exit(0) break time.

Sleep(5) def Kill(self): ''' Call from Python Window main application that causes application to exit ''' self. NeedKill = True def SetHandle(self, handle): ''' Sets Handle so thread can check if handle exists. This must be called before thread is started.''' self.

Handle = handle Again, it feels a little hackish, but I don't really see another way around it. If anybody else has better resolutions, please post.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions