[python-win32] Skip Alt+F4

Paul Moore p.f.moore at gmail.com
Mon Mar 17 12:16:53 CET 2008

On 17/03/2008, le dahut <le.dahut at laposte.net> wrote:
> I'm writting a Wx app and I want to skip Alt+F4. I've used somehting
> like that :
>     def OnKeyDown(self, event):
>         print event.AltDown(), event.GetKeyCode()
>         if event.AltDown() and event.GetKeyCode() == wx.WXK_F4:
>             print 'try to close'
> Everything gets printed but my app closes anyway on Alt+F4, is there a
> way to skip this ?

(a) you should think hard before doing this - about the only
reasonable reason for overriding the standard Alt-F4 on Windows, is to
minimise to the tray rather than closing

(b) if you still want to do this, look at the OnClose event, and override that.


More information about the python-win32 mailing list