wx.SetToolTip

222 views
Skip to first unread message

Steve

unread,
Sep 3, 2010, 1:50:04 PM9/3/10
to wxpytho...@googlegroups.com
Hello List,

I am having a problem getting a tooltip to show up when I create it dynamically. If I set the text to some default string, it displays fine but when I set it to a variable, it doesn't display. Any suggestions?

Here is the code I use to create the tool tip:

co_tt = s[23]

self.coVal.SetLabel (coStr[0:14])
self.coVal.SetToolTip (wx.ToolTip (co_tt))

if I were to make co_tt something like the follow:

co_tt = "Show tool tip"

It works.

Thanks for any help.

- Steve

Steve

unread,
Sep 3, 2010, 2:05:18 PM9/3/10
to wxpytho...@googlegroups.com
Is there a fixed length on the tooltip size? I am trying to print a location of a file which could be several directories deep. My intent is to only show the file name and on mouse-over show the entire path.

- Steve

Mike Driscoll

unread,
Sep 3, 2010, 3:00:53 PM9/3/10
to wxPython-users


On Sep 3, 1:05 pm, Steve <ghostra...@gmail.com> wrote:
> Is there a fixed length on the tooltip size? I am trying to print a location
> of a file which could be several directories deep. My intent is to only show
> the file name and on mouse-over show the entire path.
>
> - Steve
>


You may need to use TipWindow for that. I don't remember there being a
fixed length for tooltips, but I wouldn't be surprised either.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Robin Dunn

unread,
Sep 3, 2010, 4:46:06 PM9/3/10
to wxpytho...@googlegroups.com

Is s[23] a string? How big is it?

> Is there a fixed length on the tooltip size? I am trying to print a location of a file which could be several directories deep. My intent is to only show the file name and on mouse-over show the entire path.
>

On Windows at least I think that there is a limit, but I don't remember
the details. I would guess that it is something like 255 characters.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Vlastimil Brom

unread,
Sep 3, 2010, 7:04:00 PM9/3/10
to wxpytho...@googlegroups.com
2010/9/3 Robin Dunn <ro...@alldunn.com>:

For me, there doesn't seem to be a reasonable size limit for tooltips
on win XP; even a string not fitting on the whole screen can be set
(e.g. str(range(2000)) which is 10890 chars).

for the original problem, I'd guess, something else than string or
unicode is being set; would it be possible to use
self.coVal.SetToolTip (wx.ToolTip (coStr)) instead of ... co_tt ? Is
it to create an abbreviated label with a complete string as tooltip?

vbr

werner

unread,
Sep 4, 2010, 5:21:32 AM9/4/10
to wxpytho...@googlegroups.com
Steve,

On 03/09/2010 21:00, Mike Driscoll wrote:
>
> On Sep 3, 1:05 pm, Steve<ghostra...@gmail.com> wrote:
>> Is there a fixed length on the tooltip size? I am trying to print a location
>> of a file which could be several directories deep. My intent is to only show
>> the file name and on mouse-over show the entire path.
>>
>> - Steve
>>
>
> You may need to use TipWindow for that. I don't remember there being a
> fixed length for tooltips, but I wouldn't be surprised either.
>

You might also want to look at "agw.supertooltip" - check out the
wxPython demo for it (btw you will have to enlarge the dialog a bit to
make the two buttons show).

Werner

Steve

unread,
Sep 5, 2010, 4:18:53 AM9/5/10
to wxpytho...@googlegroups.com
Yes, s[23] is a string of about 50 characters. There are '/' in it but if I code those into a string statically they display just fine. It's very odd that it won't work and others just like it (same paths) work when hard coded.
 

Vlastimil Brom

unread,
Sep 5, 2010, 11:52:49 AM9/5/10
to wxpytho...@googlegroups.com
2010/9/5 Steve <ghost...@gmail.com>:

>> On 9/3/10 10:50 AM, Steve wrote:
>>>
>>> Hello List,
>>>
>>> I am having a problem getting a tooltip to show up when I create it
>>> dynamically. If I set the text to some default string, it displays fine
>>> but when I set it to a variable, it doesn't display. Any suggestions?
>>>
>>> Here is the code I use to create the tool tip:
>>>
>>> co_tt = s[23]
>>>
>>> self.coVal.SetLabel (coStr[0:14])
>>> self.coVal.SetToolTip (wx.ToolTip (co_tt))
>>>

Hi,
what widget is coVal ?
I tested tooltips with wx.Button and didn't hit any limitation (string
size, slashes, backslashes ...) - on win XPp.

vbr

C M

unread,
Sep 5, 2010, 2:00:01 PM9/5/10
to wxpytho...@googlegroups.com

Why don't you post a small runnable sample that allow others to run it
and also see the same error messages you are getting (if you're
getting any).

Steve

unread,
Sep 7, 2010, 9:39:09 PM9/7/10
to wxpytho...@googlegroups.com
coVal is a StaticText. I will do as CM suggests and try and make a small runnable that breaks it.

- STeve 
Reply all
Reply to author
Forward
0 new messages