--- "Drew, Matt" <Matt.Drew arraybiopharma.com> wrote:
> I have a wx.App that's running in MainLoop(). The
> user hits
> CTRL-C/CTRL-BREAK in the console window (on
> Windows). I want to catch
> that event and run some cleanup code before exiting.
> Nothing I can find
> will allow me to know that CTRL-C happened so I can
> run my cleanup - the
> python proces just ends immediately.
>
> I've tried using the atexit() function, and fiddling
> with
> signal.signal(signal.SIGBREAK,
> signal.default_int_handler), both of
> which work quite nicely outside of wx-enabled python
> apps. Sadly,
> neither works for apps in wx-land.
>
> So, anyone got any ideas?
Solution 1:
try:
App.MainLoop()
except KeyboardInterrupt:
App.CleanUp()
Solution 2:
Don't use a console window, so they can't hit ^C in
it.
Gre7g
____________________________________________________________
________________________
Fussy? Opinionated? Impossible to please? Perfect. Join
Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.a
sp?a=7
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|