[PythonCE] wxPython, handling close events

Matt S. sleepingbull at gmail.com
Fri Feb 23 00:31:58 CET 2007

Here's some sample code that highlights my application closing problem.  If
a user uses the Quit button, no problem.  If on the other hand they close
the frame, hay mucho problemas.

I've included some comments and commented out some code that can be used to
alter the applications behavior.  Ideally, I want the user to have to
confirm that they want to quit before the program ever begins to be


---------- Forwarded message ----------
> From: "Matt S." <sleepingbull at gmail.com>
> To: pythonce at python.org
> Date: Wed, 21 Feb 2007 21:12:08 -0800
> Subject: [PythonCE] wxPython, handling close events
> I have a a wxPython application on the PPC 2003, Python 2.4, etc...
> I can gracefully exit on win32 from the frame close button or any button
> within the frame.  My trouble arises on the PPC because the frame widgets
> (esp. close button) seem to not be associated with wx as much as the system
> and don't clean up properly.  When I tap the close circle-X, the top level
> window goes away but the Python CE window remains.  Then if I want to
> delete/replace the program my request gets refused because the original file
> is in use.  Furthermore, if I start up the file again it will run but after
> loading up, the top level window is the old tlw.
> I've been experimenting with binding close events to a pre-exit function.
> I want to either kick up a message dialog to make sure the user wants to
> exit or just veto (event.Veto()) the frame level close button event.
> self.top_window.Bind(wx.EVT_CLOSE, self.PreExit)
> I've also fooled around with the following at the application level,
> self.Bind(wx.EVT_QUERY_END_SESSION, self.OnExit)
> self.Bind(wx.EVT_END_SESSION , self.OnExit)
> I'm afraid the frame close button event I'm trying to handle is some sort
> of hybrid.
> I won't describe it here but I also have a few other issues:
> 1) when the PPC goes into sleep mode bad things happen to my app
> 2) I've tried to use PocketConsole and the kill utility to find a
> resulting hung python program file but I don't see the file as a process.
> Python.exe gets listed as a process but I'm not sure I've successfully
> ended it.  I assume that if I do, the hung python program will get cleaned
> up.
> 3) Basic PPC os questions:
> -If a python file that is being interpreted is not a process, what is it?
> -Anyone know how to clean up one of the files when it's not ended
> properly?
> If no one has a quick comment that breaks the dam, tomorrow I'll put
> together a simple example of my problem and post it for interrogation.
> Thanks!
> Matt
> Lastly, please let me know if you think this subject should be posted to a
> wxPython list (and which one).  Maybe a wxPythonCE list would be helpful in
> the near future?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonce/attachments/20070222/4f8f9fdd/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple_frame.py
Type: text/x-python
Size: 4967 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonce/attachments/20070222/4f8f9fdd/attachment.py 

More information about the PythonCE mailing list