Hi,
I wrote up an article on adding tooltips to ObjectListview last month but couldn’t figure out how to get the tooltip to display except in the first column. Today one of my readers figured out a way to do it, but neither one of us knows why it works. Could someone take a look at the end of my article and explain what’s going on so I can update it?
Here’s the link: http://www.blog.pythonlibrary.org/2013/12/12/wxpython-adding-tooltips-objectlistview/
Thanks,
Mike Driscoll
Not sure on this(haven’t looked at OLV code), but maybe whatever broke the OLV tooltips is causing tooltips to be Disabled in the OLV code.
Usually when a tooltip is disabled it does this globally for the whole widget/parents/etc.(which is strange in my opinion).
It looks that you are manually forcing the ToolTip upon each event, which Enables(globally)?!? the tooltips again.
I’m not sure why tooltips work like this in these fashions either, but I had a issue with StatusBar fields with tooltips basically hacked around the same way as this…
…Depending on the event fired off(in my case with StatusBar was EVT_MOTION and figuring out what statusbar field I was in at the time) force the tooltip to update with what infos I needed and show.
@Robin probably has a better technical answer to why this happens…???
···
On Thursday, January 23, 2014 2:56:54 PM UTC-6, Mike Driscoll wrote:
Hi,
I wrote up an article on adding tooltips to ObjectListview last month but couldn’t figure out how to get the tooltip to display except in the first column. Today one of my readers figured out a way to do it, but neither one of us knows why it works. Could someone take a look at the end of my article and explain what’s going on so I can update it?
Here’s the link: http://www.blog.pythonlibrary.org/2013/12/12/wxpython-adding-tooltips-objectlistview/
Thanks,
Mike Driscoll
I would like to share part of the logic that lead me to using “if item_index != -1”.
I tried the code in one of my personal projects and decided to see what would happen if I changed “if flag == wx.LIST_HITTEST_ONITEMLABEL:” to “if flag != wx.LIST_HITTEST_ONITEMLABEL:”.
If the widget was empty I would receive a dialog box pop up and a traceback in the command prompt. Yet, if the widget was populated the errors were not seen.
The dialog box:
Couldn’t retrieve information about list control item -1.
The Traceback:
Traceback (most recent call last):
File “E:\ECT\panelMeta.py”, line 220, in updateTooltip
self.dataOLV.GetObjectAt(item_index).name,
File “E:\Python\App\lib\site-packages\ObjectListView\ObjectListView.py”, line
1115, in GetObjectAt
return self.innerList[self.GetItemData(index)]
IndexError: list index out of range
I know the errors were caused by attempting to get data from a blank row, so I thought it was a logical choice to check the row and verify it was not blank.
It still confuses me that it is working this way, but at least now everyone has an idea of the thought process that lead to my conclusion. Even if it still doesn’t answer the question of why it is working.