I'm embedding a FigureCanvasWxAgg into a wx.Panel and binding key events to
def __init__(self, parent, file, id=-1):
style=wx.WANTS_CHARS | wx.NO_FULL_REPAINT_ON_RESIZE)
#Set up the canvas
self.figure = Figure((9,8),75)
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
self.subplot = self.figure.add_subplot(111)
#Set up the toolbar
self.toolbar = NavigationToolbar2Wx(self.canvas)
tw, th = self.toolbar.GetSizeTuple()
fw, fh = self.canvas.GetSizeTuple()
#Set up figure manager
self.figmgr = FigureManager(self.canvas, 1, self)
def self.__keyup(self, evt):
print 'key up'
def self.__keydown(self, evt):
print 'key down'
The program successfully detects keydown events for just about every key
with three major exceptions: wx.WXK_RETURN, wx.WXK_RIGHT, wx.WXK_LEFT.
There may be other keys out there, but those three keys are the ones I need
to process events for.
I've tried subclassing FigureCanvasWxAgg and defining key_press_event (which
doesn't seem to work) and overriding _onKeyDown (which still does not
capture the keys I need). Something weird seems to be happening to these
keys, and was wondering if anyone could help me?
I am able to detect the EVT_KEY_UP for these three keys. Just not the key