Hello,
I am trying to capture keyboard events. Here is some stripped down code
at my attempt.
It doesn't seem to react to key presses?
Any help would be very appreciated!
thnx,
Ray Sells
import wx
class Frame( wx.Frame):
def __init__( self, image = None, parent = None, id = -1,
pos = wx.DefaultPosition,
title = 'C++ Model Developer'):
"""Create a Frame instance and display an image."""
wx.Frameinit__( self, parent, id, title, pos, size = ( 400, 300))
panel = wx.Panel( self)
panel.button = wx.Button( panel, -1, "Close", pos = ( 100, 100))
self.Bind( wx.EVT_BUTTN, ButtonClick)
self.Bind( wx.EVT_KEY_DWN, Key)
def ButtonClick( self, event):
print "Button clicked!"
def Key( self, event):
k = event.GetKeyCode()
print "key code is", k
class App( wx.App):
def Init( self):
self.frame = Frame()
self.frame.Show()
self.SetTopWindow( self.frame)
return True
def main():
app = App( False)
app.MainLoop()
if __name__ == '__main__':
main()