Closing dialog window on ESC

Basically, I want to close a window/dialog on ESC. E.g. About program
dialog, or Config dialog.

Have you tried :
wxWindow::OnCharHook
According to the documentation :
An example of using this function is in the implementation of escape-character processing for wxDialog, where pressing ESC dismisses the dialog by OnCharHook 'forging' a cancel button press event.

Cheers,
Arye.

Hi...
This is a simple way to make your frame to close on escape.
Modified your code see below.... (worked for me...)

···

------------------------------------------------------------------
from wxPython.wx import *
class MainWindow(wxFrame):
    def __init__(self, parent, id, title):
        wxFrame.__init__(self, parent, -4, title, size = (200, 100),
                        style = wxDEFAULT_FRAME_STYLE)
        self.control = wxTextCtrl(self, 1, style = wxTE_MULTILINE)
        self.Show(True)

        EVT_CHAR(self.control, self.OnKeyDown)

    def OnKeyDown(self, event):
# print "Some key pressed, still don't know which one"
        if event.GetKeyCode() == WXK_ESCAPE:
            self.Destroy()
        else:
            text = self.control.GetValue() + unichr(event.GetKeyCode())
            self.control.SetValue(text)
            self.control.SetInsertionPointEnd()

app = wxPySimpleApp()
frame = MainWindow(None, -1, "KeyDownTest")
app.MainLoop()

--------------------------------

Good luck!
Holmgren