Hi,
I’m trying to implement ToolTips for a grid column.
Googling brought me to http://wiki.wxpython.org/BalloonTip, but the examples referred to there are in the non-existent page (http://jump.xoom.alice.it/jump.htm).
Do any of you have a code snippet demonstrating how to add balloon tooltips to a grid column/cell ?
Thanks,
Ron.
Ron,
Hi,
I'm trying to implement ToolTips for a grid column.
Googling brought me to BalloonTip - wxPyWiki, but the examples referred to there are in the non-existent page (http://jump.xoom.alice.it/jump.htm).
Do any of you have a code snippet demonstrating how to add balloon tooltips to a grid column/cell ?
Thanks,
Ron.
Looks like that's an old link. Hopefully Andrea will edit that page...otherwise, I'll have to try to remember how to do it. In the mean time, try going here instead: http://xoomer.alice.it/infinity77/main/BalloonTip.html
Mike
Thanks Andrea: the demo works like a charm.
I noticed that it does not demo how to implement tooltips on a grid.
Do you - by chance - have a code snipped demonstrating how to use BalloonTip for a grid column/cell ?
Bye,
Ron.
···
-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Wednesday, October 08, 2008 10:10
To: Barak, Ron
Subject: Re: [wxpython-users] Adding balloon tooltips to a grid column/cell ?
Hi Ron,
On Wed, Oct 8, 2008 at 9:04 AM, Andrea Gavana wrote:
Hi Ron,
On Wed, Oct 8, 2008 at 8:13 AM, Barak, Ron wrote:
Hi,
[Barak, Ron] Hi Andrea,
When I try to run the BalloonTipDemo.py demo, I get:
$ python tooltip/BalloonTipDemo.py
Traceback (most recent call last):
File "tooltip/BalloonTipDemo.py", line 350, in <module>
frame = DemoFrame(None, -1, "Balloon Tip Demo", size=(600,400))
File "tooltip/BalloonTipDemo.py", line 132, in __init__
controls.append(tbicon)
AttributeError: 'WindowList' object has no attribute 'append'
And indeed:
type(controls)== <class 'wx._core.WindowList'> ;
dir(controls)== ['__class__', '__contains__', '__del__',
'__delattr__', '__dict__', '__doc__', '__getattribute__',
'__getitem__', '__hash__', '__init__', '__iter__', '__len__',
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__str__', '__swig_destroy__', '__weakref__', 'index',
'this', 'thisown']
Uhm, it's been a while since I have used (and checked) BalloonTip,
something has changed in wxPython since then... I'll fix this bug
today and I'll let you know.
Ok, it was just a small issue... GetChildren() previously returned a list of controls (a long time ago), while now it returns a WindowList.
It's fixed, just in case you wish to try it again.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
Hi Ron,
Thanks Andrea: the demo works like a charm.
I noticed that it does not demo how to implement tooltips on a grid.
Do you - by chance - have a code snipped demonstrating how to use BalloonTip for a grid column/cell ?
I have never tried with a grid, but in theory it should work... You
build your BalloonTip normally, and then call SetTarget on the grid
window:
balloonTip.SetTarget(yourGrid.GetGridWindow())
That should do...
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
···
On Wed, Oct 8, 2008 at 9:33 AM, Barak, Ron wrote:
Ron,
Hi,
I'm trying to implement ToolTips for a grid column.
Googling brought me to BalloonTip - wxPyWiki, but the examples referred to there are in the non-existent page (http://jump.xoom.alice.it/jump.htm).
Do any of you have a code snippet demonstrating how to add balloon tooltips to a grid column/cell ?
Thanks,
Ron.
After re-reading this, I realized that I already do this in one of my applications using the default tooltips. In your application's __init__, you'll need to initialize your tooltip variable to an empty string:
self.tooltip = ""
Then to bind to the column area, do this:
self.myGrid.GetGridColLabelWindow().Bind(wx.EVT_MOTION, self.onMouseOver)
Finally, in my MouseOver event, I do something like this:
<code>
def onMouseOver(self, event):
'''
When the mouse is hovered over certain columns, a tooltip will be
displayed to give the user more information about what data should
go into that specific column
'''
pos = event.GetX()
if pos > 130 and pos < 180:
if self.tooltip != 'Regular Hours':
self.sheet.GetGridColLabelWindow().SetToolTipString('Regular Hours')
self.tooltip = 'Regular Hours' elif pos > 180 and pos < 230:
if self.tooltip != 'Overtime Hours':
self.sheet.GetGridColLabelWindow().SetToolTipString('Overtime Hours')
self.tooltip = 'Overtime Hours' else:
if self.tooltip != '':
self.sheet.GetGridColLabelWindow().SetToolTipString('')
self.tooltip = ''
event.Skip()
</code>
You'll need to figure out the widths of your own columns yourself and change the numbers in the "if" statements accordingly, of course. I hope that helps!
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org