Escape key event problem in wxPython?

Posted by MA1 on Stack Overflow See other posts from Stack Overflow or by MA1
Published on 2010-03-08T05:46:20Z Indexed on 2010/03/08 5:51 UTC
Read the original article Hit count: 604

Filed under:

Hi All

The following key event is not working. Any idea?

class Frame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, -1, title='testing', size=(300,380),                      style=                                                                                        wx.MINIMIZE_BOX|wx.SYSTEM_MENU
                                                                                            |wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)  

        self.tree = HyperTreeList(self, style = wx.TR_DEFAULT_STYLE |
                                                wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HAS_VARIABLE_ROW_HEIGHT | wx.TR_HIDE_ROOT)

        # create column
        self.tree.AddColumn("coll")

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

 def OnKeyDown(self, event):
        keycode = event.GetKeyCode()
        print "keycode ", keycode
        if keycode == wx.WXK_ESCAPE:
            print "closing"
            self.Close()

Regards,

© Stack Overflow or respective owner

Related posts about wxpython