plot.py override event binding

Roger Jarvis wrote:

Hi,

I want to override the event binding in plot.py to introduce a contextual menu when right mouse clicking on a plotcanvas. But it doesn't seem to want to work. If anyone can help with this it would be great.

$ pydoc wx.lib.plot.PlotCanvas
Help on class PlotCanvas in wx.lib.plot:

wx.lib.plot.PlotCanvas = class PlotCanvas(wx._windows.Panel)
  > Subclass of a wx.Panel which holds two scrollbars and the actual
  > plotting canvas (self.canvas). It allows for simple general plotting
  > of data with zoom, labels, and automatic axis scaling.
  >

So the window you need to bind the event to is self.plotCanvas1.canvas, not self.plotCanvas1. On the other hand we've got the EVT_CONTEXT_MENU event that is a command event so it will traverse up the containment hierarchy, so you can bind that directly to your frame. It will also be triggered in whatever is the native way on each platform, (button down vs. button up.)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!