Setting a tooltip to None

The code:

t = wx.ToolTip("Test tip")
win.SetToolTip(t)

appears to work as expected. Now, how do I clear the tip for the window? I've tried the following:

win.SetToolTip(None) ## boom
win.SetToolTip(-1) ## boom

# The following works...
t = wx.ToolTip("")
win.SetToolTip(t)
# ... but I get a little blank tooltip window

# Same with:
t.SetTip("")
win.SetToolTip(t)

I've tried using Enable(), but this appears to do what the docs say and disable tooltips globally. IOW, my other tooltips for other windows are also disabled.

I also just tried:
win.GetToolTip().Destroy()

which rewarded me with a segfault.

So... am I going crazy? How do I say "Make this window no longer have a Tooltip?"

···

--
Paul

Hello Paul,

So... am I going crazy? How do I say "Make this window no longer have a
Tooltip?"

I haven't found anything about this issue (but surely Robin will know the
answer) but, what about using wx.TipWindow() instead? In my opinion it is
much more customizable than a simple SetToolTip...

Just my 2c.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77

Relax man, this might be just a bug in wxPython, you know… Robin is only human… nice of you to catch it :slight_smile:

As a temporary fix until things get cleared… you could go extreme and replace the window with the tooltip with a fresh one without a tooltip, I know is ugly (sizer messing required), but it should work.

Also… you should post your basic specs, at least platform and wxpython version, this might be platform specific.

Peter. :slight_smile:

···

On 2/15/06, Paul McNett p@ulmcnett.com wrote:

So… am I going crazy? How do I say “Make this window no longer have a
Tooltip?”

Paul McNett wrote:

The code:

t = wx.ToolTip("Test tip")
win.SetToolTip(t)

appears to work as expected. Now, how do I clear the tip for the window? I've tried the following:

win.SetToolTip(None) ## boom

This is the way it is supposed to work, and it does for me as seen from this PyShell session:

  >>> import wx
  >>> print wx.VERSION, wx.PlatformInfo
  (2, 6, 2, 1, '') ('__WXMSW__', 'wxMSW', 'unicode', 'wx-assertions-on')
  >>> f = wx.Frame(None)
  >>> p = wx.Panel(f)
  >>> f.Show()
  True
  >>> tt = wx.ToolTip("Hello Paul")
  >>> p.SetToolTip(tt)
  >>> p.SetToolTip(None)
  >>>

What platform and version are you using?

···

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

I'm sorry everyone, I really should have done a better job with my first message. Here's a test script I just ran given Robin's proposed solution. It doesn't go boom like I originally said, but it also has no effect on the ToolTip display, even though o.GetToolTip() does return None.

I tested this on:
(2, 6, 1, 1, 'pre') ('__WXGTK__', 'wxGTK', 'unicode', 'gtk2', 'wx-assertions-off')

Andrea, thanks for suggesting wx.TipWindow(). I had no idea it even existed and I'll check it out straightaway.

Here's my output of the attached script:

pmcnett@sol:~/projects/daboide$ python test.py
(2, 6, 1, 1, 'pre') ('__WXGTK__', 'wxGTK', 'unicode', 'gtk2', 'wx-assertions-off')
<wx._misc.ToolTip; proxy of C++ wxToolTip instance at _20c63f08_p_wxToolTip>
None

test.py (366 Bytes)

···

--
Paul

Paul McNett wrote:

I'm sorry everyone, I really should have done a better job with my first message. Here's a test script I just ran given Robin's proposed solution. It doesn't go boom like I originally said, but it also has no effect on the ToolTip display, even though o.GetToolTip() does return None.

I tested this on:
(2, 6, 1, 1, 'pre') ('__WXGTK__', 'wxGTK', 'unicode', 'gtk2', 'wx-assertions-off')

Looks like setting it to None is not explicitly removing the tooltip from the GTK control. I don't see an obvious solution so it will need to be done by somebody that knows GTK better than me. Please enter a bug report about this.

···

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