Connecting Mouse Double Click...

Hello Chris,

Are you using MPL with wxPython? I'd expect so.

Yes, I am using it with wxPython, and I am sometimes frustrated by the
difficulty to find which method in matplotlib API does something that Pylab
does with another syntax.

Make sure to check out wxmpl and/or Mplot:

I have checked wxmpl, but it seems to me that it has the same mouse events
as matplotlib has (button down/up/motion) and nothing more. Moreover, both
matplotlib and wxmpl fail to get the mouse_down event if you click very fast
on the figure canvas. I mean, I can click say 30 times in 10 seconds on the
MPL canvas, but only 20 clicks get captured by the event. So it's quite
difficult to hack the single mouse_down event to simulate the double-click
because quite often MPL misses a mouse click...
wxmpl suffers of the same desease, from my tests. So I ended up in a dirty
hack of a MPL single mouse_down to transform it in a double-click, but quite
often I have o click 3/4 times to get the double-click working.
I don't think it's the slowness of my PCs, because they are quite fast.

Thank you very much for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

Andrea Gavana wrote:

I have checked wxmpl, but it seems to me that it has the same mouse events
as matplotlib has (button down/up/motion) and nothing more.

wxmpl provides a subclass of wxPanel, so it's there somewhere. I haven't done mouse events, so I I don't know where yet. I do think wxmpl could use some more work.

matplotlib and wxmpl fail to get the mouse_down event if you click very fast
on the figure canvas.

I'm guessing that what's happening is that the two mouse clicks close together are getting caught as a double-click, so the second one doesn't show up as a single click.

So I ended up in a dirty
hack of a MPL single mouse_down to transform it in a double-click,

ugh. I'd poke around more in the wxmpl code. Maybe I'll do that myself.

OK-- I started doing that, but first I just tried binding a event to a wxmpl.PlotPanel, and it works fine. I've enclosed a little sample. It should write to the console when you left, right or double-left click on the PlotPanel.

Note that when you double click, you get one left click event and one double click event, but not two left click events.

Of course, you'll now need to figure out how to query the FigureCanvas to see what the axes coords are, but I'm sure you can find code on MPL that will give you hints.

By the way, you could hack backend_wx.py to add the double click events, but that would be ugly if it wasn't added everywhere else in MPL -- which is kind of why I think that way lies madness :wink:

-Chris

wxMplSample.py (2.38 KB)

ยทยทยท

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...