example: wx.ToolTip for MPL axes

Not sure if this already exists, but here's an example file of how to get a wx.ToolTip to pop up and report the current mouse position in data coordinates over a MPL axes. Not sure if it's the best way of doing this, but it seems to work really well for me. Perhaps it would be useful to add this to the MPL examples?

Cheers,

Martin

wxtooltip_example.py (1.01 KB)

Here's an updated version. mpl.use('WXAgg') should come before importing pylab.

Martin

Martin Spacek wrote:

wxtooltip_demo.py (1.01 KB)

···

Not sure if this already exists, but here's an example file of how to get a wx.ToolTip to pop up and report the current mouse position in data coordinates over a MPL axes. Not sure if it's the best way of doing this, but it seems to work really well for me. Perhaps it would be useful to add this to the MPL examples?

Cheers,

Martin

And here's yet another refinement. Works around a wx bug (see http://article.gmane.org/gmane.comp.python.wxpython/37937/match=tooltip) that prevents newlines from being recognized in the tooltip string. Also, disables the tooltip when the mouse moves off of the axes, which prevents stray tooltips from hanging around.

Martin

Martin Spacek wrote:

wxtooltip_demo.py (1.45 KB)

···

Here's an updated version. mpl.use('WXAgg') should come before importing pylab.

Martin

I've updated the docstring with a comment about display issues in wxGTK.

Martin

Martin Spacek wrote:

wxtooltip_demo.py (1.57 KB)

···

Not sure if this already exists, but here's an example file of how to get a wx.ToolTip to pop up and report the current mouse position in data coordinates over a MPL axes. Not sure if it's the best way of doing this, but it seems to work really well for me. Perhaps it would be useful to add this to the MPL examples?

Cheers,

Martin