[PythonCE] wxPython, handling close events
sleepingbull at gmail.com
Mon Feb 26 21:53:13 CET 2007
You wrote on 2/23/07, in response to my inquiry about how to handle what are
generally close events on Windows (but not on CE),
You may be able to capture the event as WM_SHOWWINDOW.
Should this event be captured through wxPython or do I have to use ctypes or
What follows is my rant about the painful small problems I'm encountering,
my feeling that the Wiki really needs to get some love/content (especially
for using wxPython and how to successfully emulate Python/wx on a PocketPC
emulator), and some other leads I have for how to handle the closing
problem. Any words of wisdom or insight are appreciated.
I'm pretty much beat by this issue at this point. First off, I'm amazed how
much work and functionality is available in wxPython for CE, but (now my
rant), it's pretty frustrating (to say it lightly) when so much of Python
works beautifully on CE and then (at least wrt wxPython) small things turn
into such ghastly demons. I keep fighting (maybe believing) that my
organization will be the better for rejecting a 500 pound gorilla and going
with wx/Python on this project... but days (as in multiple) like these make
me think either we shouldn't mess with CE/Mobile/whatever and just stick to
Windows (and maybe Linux if only there were more users) or go with a
language that is more targeted/supported by the CE environment (Visual
Basic??? Please, no!) and documented.
>From my standpoint, as a scientist who develops, I'm not really an expert
wrt to anything. But I feel I can generally bridge the gap between a real
world problem and derive a solution using (almost always) Python. But
bosses, peers, even me want to see functionality and I don't want to have to
be an expert on the intricacies of every os just to figure out how to
gracefully close a program.
That said, this seems to be a problem that anyone who is programming on the
PocketPC and wants to use wxPython for their interface will have to solve.
I hope to find a solution to this problem and get the issue and solution
posted to the wiki (either with my own 10 fingers or through someone who
knows the solution which surely someone does). The wiki:
(there's not a single page about wxPython there!).
Regarding new info I have about solving this problem,
I'm thinking I either need to implement a WindowProc function that processes
messages sent to the window,
or, hope that the WS_NONAVDONEBUTTON gets supported by wx and then ported to
the PPC (or learn to compile, etc. myself),
One last thing, being a relative novice, solving this problem is seriously
compounded because I haven't seen a simple explanation of (or mention that)
Python/wx will work in any of the PPC emulators.
I hope I'm not stepping on toes but instead making PythonCE/wxPython more
accessible by asking the "stupid questions,"
On 2/23/07, Luke Dunstan <coder_infidel at hotmail.com> wrote:
> As with any Pocket PC application (written in Python or otherwise), the X
> "close" button merely hides a window and does not destroy it. The Pocket PC
> platform is intended so that users don't need to "close" applications as
> such, and if you open enough other applications that the memory starts to
> become full, the OS will actually close (WM_CLOSE) some of the applications
> that were hidden in the background. If you try clicking the X button on
> any of the Microsoft's Pocket PC applications, e.g. Pocket Word, and then
> look in the task manager you will notice that it is still running.
> You may be able to capture the event as WM_SHOWWINDOW.
> As with any Python program on the PC, your script is not a process but is
> just a text file that is interpreted by the python.exe process.
> ----- Original Message -----
> *From:* Matt S. <sleepingbull at gmail.com>
> *To:* pythonce at python.org
> *Sent:* Thursday, February 22, 2007 2:12 PM
> *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
> 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
> 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.
> 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...
More information about the PythonCE