Problems emulating the wxToolTip (using wxTipWindow) for icons (images) on Tabs of a wxNotebook

I've been trying to make tool tips for images on a wxNotebook. In an
earlier post
(http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?11:mss:16218:200302:bcpikopnobfkkmmdibkd) it
was suggested I try the wxTipWindow class because the wxToolTip class
doesn't work with a wxNotebook.

Attached is some code (--all of the stuff relevant to the post is in the
class that inherits from 'wxNotebook'). It, aside from a few quirks, does
what I want it to. The problem is it is a really bad hack. It has a
window decorations dependence. In other words, it works with the 'KDE 2'
decorations in KDE3.1, but has problems if I use the 'Keramik'
decorations.

The real problem is that the tool tip activation is based on coordinate
data.
Q. Is there an alternative here? Can the wxTipWindow somehow be attached
to an image?

Also, I've found that wxTipWindow's 'SetBoundingRect' method takes the
screen coordinates. I find this is a big problem for what I'm doing
because I generally don't know where my panel is located on the screen--I
didn't manage to find a method for getting the screen coordinates for an
object that is non-top level (the 'GetPosition' method returns coordinates
only relative to the parent). Problem is I want to use the code in two
different environments--one where the top-level window is the grandparent
of the wxNotebook... another where it is the great-grandparent.
Q. Is there a way to get screen coordinates from within non-top level
objects?
Alternatively... Is there an easy way for an object to determine its top
level window?
Alternatively... Can the 'SetBoundingRect' coordinates be made relative to
the object from which it is called?

tooltip_hack_gmGP_TabbedList_d10.py (17.9 KB)

···

---
Am I missing something obvious?

I've run-out of ideas and can't help but think changes in the wxPython
code would be the best path to stable & portable code.
Q. Is the wxNotebook class going to include the ability to attach
wxToolTip objects to the tabs in the near future?

Any help would much appreciated.
Michael

Michael Bonert wrote:

I've been trying to make tool tips for images on a wxNotebook. In an
earlier post
(http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?11:mss:16218:200302:bcpikopnobfkkmmdibkd) it
was suggested I try the wxTipWindow class because the wxToolTip class
doesn't work with a wxNotebook.

Attached is some code (--all of the stuff relevant to the post is in the
class that inherits from 'wxNotebook'). It, aside from a few quirks, does
what I want it to. The problem is it is a really bad hack.

Yes, I didn't expect that it would be otherwise since wxNotebook doesn't give you any info about where the tabs are.

It has a
window decorations dependence. In other words, it works with the 'KDE 2'
decorations in KDE3.1, but has problems if I use the 'Keramik'
decorations.

The real problem is that the tool tip activation is based on coordinate
data.
Q. Is there an alternative here? Can the wxTipWindow somehow be attached
to an image?

No, because the image is just a bunch of bytes, it has no screen location all by itself. Also, there is no way to know what the notebook is going to do with the image you give it, nor where it is going to place it.

Also, I've found that wxTipWindow's 'SetBoundingRect' method takes the
screen coordinates. I find this is a big problem for what I'm doing
because I generally don't know where my panel is located on the screen--I
didn't manage to find a method for getting the screen coordinates for an
object that is non-top level (the 'GetPosition' method returns coordinates
only relative to the parent). Problem is I want to use the code in two
different environments--one where the top-level window is the grandparent
of the wxNotebook... another where it is the great-grandparent.
Q. Is there a way to get screen coordinates from within non-top level
objects?

Use window.ClientToScreen(pos) which will translate some position in client coordinants for some window into screen coordinants.

Alternatively... Is there an easy way for an object to determine its top
level window?

toplevelparent = wxGetTopLevelParent(window)

Alternatively... Can the 'SetBoundingRect' coordinates be made relative to
the object from which it is called?

No.

---
Am I missing something obvious?

No.

I've run-out of ideas and can't help but think changes in the wxPython
code would be the best path to stable & portable code.
Q. Is the wxNotebook class going to include the ability to attach
wxToolTip objects to the tabs in the near future?

Nothing is planned.

Any help would much appreciated.

So would patches to the C++ wxNotbook class for the various platforms. :wink:

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!