Hi all,
I'm trying to work out how to use tooltips with wx.lib.floatcanvas. As I was thinking about this, Martin Spacek posted a sample of how to do it with wx and matplotlib to the MPL list.
However, his methods don't quite work right on wxGTK. I've been playing around with this, and am not getting it to work like I want it to. Ideally, I want to be able to pop up a tooltip wherever and whenever I want, but it's looking to be impossible. I'm guessing that wx.ToolTip is using the native tooltip support, and thus has little control over behavior.
I have a few particular issues, maybe someone has some ideas of how to improve them. Enclosed is a small demo app. It has two panels, each with slightly different tooltip behavior attempted.
The top panel shows a tooltip when the mouse is clicked. This works OK. However, getting it to go away is a trick. I tried to use:
wx.TipWindow.SetBoundingRect()
but it seems to have the opposite behavior than I expected. Now the tip window goes away when the mouse passes over the tip, NOT when it leaves the region specified by the rect. What am I doing wrong?
I also tried to have the TipWindow destroyed when the mouse left the window, but it seems I don't get the EVT_LEAVE_WINDOW when the tooltip is active -- weird. I also don't know how to make it go away -- should .Destroy() work?
The bottom Panel has a tooltip that shows the mouse coords. Ideally it would follow the mouse around. I think that works on Windows, but on wxGTK, it follows the x-coord, but stays at the bottom of the Panel. Can I fix that?
Also, I tried to make it so the tip would only show when the mouse was over the rectangle, but once ToolTip.Enable(False) is called, ToolTip.Enable(True) doesn't bring it back.
Can anyone figure out how to do this on all platforms? (wxMac is worse, I think)
I also wonder what the "global" means with that call:
"""
wxToolTip::Enable
Enable or disable tooltips globally.
"""
Global to what? the application? the Window? the Frame?
If none of this can be made to work right, is it possible to make a Custom pop-up Window that looks like a tooltip?
Thanks,
-Chris
ToolTips.py (3.6 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