Thanks for the help Ken and Christopher! Attached is an example file of what I've got running now. It should run on its own. A wx tooltip pops up whenever the mouse is over the axes. The tooltip's hangs obediently off of the bottom right of the mouse cursor. Its string is updated to reflect the current position of the mouse in data coordinates.

I'll make a post to the devel list, maybe get this added to the MPL examples.

Cheers,

Martin
"""Example of how to use wx tooltips on a matplotlib figure window.
A tooltip pops up and tracks the mouse when the mouse is above the
axes, updating it's value with the current x and y data values under
mouse position"""

import matplotlib as mpl
import pylab as pl
from pylab import get_current_fig_manager as gcfm
import wx

mpl.use('WXAgg')
mpl.interactive(False)


class wxToolTipExample(object):

    def __init__(self):
        self.f = pl.figure()
        self.a = self.f.add_subplot(111)
        self.tooltip = wx.ToolTip(tip='') # create an empty tooltip
        self.tooltip.SetDelay(500) # set popup delay in ms
        gcfm().canvas.SetToolTip(self.tooltip) # connect tooltip to canvas
        self.f.canvas.mpl_connect('motion_notify_event', self.onmotion)

    def onmotion(self, event):
        """Called during mouse motion over figure"""
        if event.xdata != None and event.ydata != None:
            self.tooltip.SetTip(tip='x=%f, y=%f' % (event.xdata, event.ydata))

example = wxToolTipExample()

pl.show()
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to