tooltips in matplotlib?

Hi,

I'd like to be able to pop up a tooltip on, say, a matplotlib 'motion_notify_event', or maybe just a 'button_press_event'. Does MPL have the ability to control tooltips, or do I have to drop down to the specific backend to do that (wxagg in my case).

If the latter, anyone know off the top of their head how to do this in wxagg?

Thanks,

Martin

I'd like to be able to pop up a tooltip on, say, a matplotlib
'motion_notify_event', or maybe just a 'button_press_event'. Does MPL
have the ability to control tooltips, or do I have to drop down to the
specific backend to do that (wxagg in my case).

I don't think there's a backend-level API for drawing tooltips.

If the latter, anyone know off the top of their head how to do this in
wxagg?

Unfortunately, I don't think wxWidgets exposes the functionality for displaying a wx.ToolTip. You might be able to fake it with a wx.PopupWindow.

Ken

···

On Sep 11, 2006, at 5:28 PM, Martin Spacek wrote:

Ken McIvor wrote:

Unfortunately, I don't think wxWidgets exposes the functionality for displaying a wx.ToolTip.

Yes, it does, though I haven't used it:

wx.TipWindow

Shows simple text in a popup tip window on creation. This is used by wx.SimpleHelpProvider to show popup help. The window automatically destroys itself when the user clicks on it or it loses the focus.

You may also use this class to emulate the tooltips when you need finer control over them than what the standard tooltips provide.

-Chris

···

--
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...

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

wxtooltip_example.py (1.01 KB)

Martin Spacek wrote:

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.

cool.

I had to make a change to get it to run:

mpl.use('WXAgg') has to come before "import pylab"

once running, it's not working quite right: the tooltip always is at the bottom of the Window, though it does track the X location.

oddly it looks likeit's getting it's coords in figure units (0 to 1), whcih shouldn't work with a wxWindow.

Also, I'm getting the tooltip even when the window doesnot have focus and is under other windows -- at least when the mouse is over an exposed part of the window. That's probably a wx issue.

Python 2.4.3
>> wx.__version__
'2.6.3.0'
>>> matplotlib.__version__
'0.87.5'

wxGTK on on Fedora core 4 linux.

-Chris

···

--
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...