You'll find that the app gets a Windows message on an attempt to
shutdown the app externally (other than being killed by taskman or the like, which just kill it dead w/out a message), see the wxApp docs for that.
The big problem is that you need the programme to be hidden so the user can't just kill the process with taskmanager to "log out" and get free access time. I don't know of a way to do that hiding in wxPython. I know it's possible with Win32, but I'm not sure there's a Python wrapping of the code necessary to do it. Alternately, you can disable taskman with a flag somewhere, but it's a useful utility IMO.
Another option would be to use the winlogon notification of an exit to run a "logout" script. Again, I don't know of any way to do that in pure Python.
I'd guess you could do something with creating a Service that just updates your dbase every X minutes with the currently logged-in user's name (I think you can get that from the win32api). Since the service would be system-level, the unpriveledged user can't get to it.
If you don't care about the user being able to kill the process, then the wxApp with Windows message handler should work. You could create an "at" job that auto-restarts the app if the user kills it I suppose. That's probably the lowest-effort approach? Don't know.
BTW: How do you deal with crashes/network failures/power failures/etceteras? Without an active-scan (each machine reporting every X seconds while connected), you could have someone use up all their hours just because something crashed their machine.
Sorry, no other thoughts at the moment,
Mike
John Hopkins wrote:
···
I have a simple wxPython app that is used in a school computer lab.
> Students log in with it, then leave it running and click a button on a
> small form when they are ready to leave/shut down the computer. It logs
> the time in and time out, among other things, in a MySQL database. What
> the lab director really wants is for the app to "hide" completely once
> the user has logged in, and when Windows shuts down to trap whatever
> event is available and record time out in the database, then gracefully
> exit. The environment is a mix of Win2K and Nt 4 in two labs. I
> haven't been able to figure this out, perhaps because I've never gotten
> very deep into either wxPython or WinAPI. Any help much appreciated.
>
> Thanks,
>
> John Hopkins
>
--
_______________________________________
Mike C. Fletcher
http://members.rogers.com/mcfletch/