pick_event with wxmpl

Do you know if there is a reason why I cannot succeed in generating a
pick_event using wxmpl?
I know I could use EVT_POINT but I need the picker event to return the event.ind

thanks!

Do you know if there is a reason why I cannot succeed in generating a
pick_event using wxmpl?

Yes, WxMpl disables all matplotlib events to ensure that figure zooming works correctly. I haven't had time to ensure that WxMpl will work reliably in all cases when matplotlib's events are enabled.

I know I could use EVT_POINT but I need the picker event to return the event.ind

Although it's a bit silly, one possible solution would be to have your EVT_POINT callback generate a mouse event. I think something like this might work, but I haven't tried it...

from matplotlib.backend_bases import FigureCanvasBase

def OnPoint(evt):
  figureCanvas = evt.axis.figure.canvas
  FigureCanvasBase.button_press_event(figureCanvas, evt.x, evt.y, 1)

Ken

···

On Oct 12, 2007, at 4:28 PM, Giorgio F. Gilestro wrote:

Thank you Ken,
I ended up doing more or less as you suggested but it turns out that
with the new pick API is actually much easier:

    wxmpl.EVT_POINT(self, self.GetId(), self.onPoint)
    self.mpl_connect('pick_event', self.onPick)

    def onPoint(self,event):
       '''
       Called by the EVT_POINT of wxmpl. Generates a pick_event
       '''
       event.axes.pick(event)

    def onPick(self,event):
       '''
       Called upon a pick_event
       '''
       print 'You picked %s' % event.ind

GG

···

On 10/15/07, Ken McIvor <mcivor@...612...> wrote:

On Oct 12, 2007, at 4:28 PM, Giorgio F. Gilestro wrote:
>
> Do you know if there is a reason why I cannot succeed in generating a
> pick_event using wxmpl?

Yes, WxMpl disables all matplotlib events to ensure that figure
zooming works correctly. I haven't had time to ensure that WxMpl will
work reliably in all cases when matplotlib's events are enabled.

> I know I could use EVT_POINT but I need the picker event to return
> the event.ind

Although it's a bit silly, one possible solution would be to have
your EVT_POINT callback generate a mouse event. I think something
like this might work, but I haven't tried it...

from matplotlib.backend_bases import FigureCanvasBase

def OnPoint(evt):
        figureCanvas = evt.axis.figure.canvas
        FigureCanvasBase.button_press_event(figureCanvas, evt.x, evt.y, 1)

Ken