Problem with wxTipWindow

hi,

i earlier posted one question asking whether we can put a ToolTip for the list items in a List Ctrl

Robin replied to this by saying that i need to catch the mouse events for ListCtrl snd detect when mouse is hovering.

Truely speaking robin, i didn’t really get how to proceed.

Anyways i tried doing it in many ways…

in ListCtrl we have only events for mouse click…so i went for " wx.EVT_MOTION"

self.list.Bind(wx.EVT_MOTION, self.OnMouseMove)

def OnMouseMove(self,event):

self.x = event.GetX()
self.y = event.GetY()
item, flags = self.miblist.HitTest((self.x, self.y))
if flags & wx.LIST_HITTEST_ONITEMLABEL

#rect = wx.Rect(self.x,self.y, 20,20)
#self.tip = wx.TipWindow(self, ‘Rect: %s’ % rect)
#self.tip.SetBoundingRect(rect)
#self.tip.Show()

#if item ==0:
rect = wx.Rect(self.x,self.y, 20,20)
tipWin = wx.TipWindow(self.miblist, “Description of item 1”)
tipWin.SetBoundingRect(rect)

what happens is :

  1. if i am not using SetBoundingRect(), then the TipWindow diappears only the user clicks.

  2. when i set the above function the TipWindow comes but the text is not coming in that window., just a box comes.

really don’t understand wtaz happening. The main prob is i have many list items and for each list item the text in the tip window should change. so it si necessaty that the old tip winder should diappear when the mouse move to the new item.

Also when using TipWindow i am not able to select a list item properly ie, if i try to select by clicking at certain points it won’t be selected. Don’t know why?( iam using wx.EVT_LIST_ITEM_SELECTED for selecting a list item)

MyPanel.py (5.4 KB)

OpenDialog.py (2.23 KB)

···


Regards,

Shine Anne

Shine Anne wrote:

hi,
i earlier posted one question asking whether we can put a ToolTip for the list items in a List Ctrl
Robin replied to this by saying that i need to catch the mouse events for ListCtrl snd detect when mouse is hovering.
Truely speaking robin, i didn't really get how to proceed.
Anyways i tried doing it in many ways...
in ListCtrl we have only events for mouse click..so i went for " wx.EVT_MOTION"

Normally a hover test would start in an EVT_MOTION event, but it would just set a timer there. If there is another motion event before the timer expires, or if the mouse moves more than a certain number of pixels, then reset the timer to the wait time again. If the mouse leaves the window then the timer should be stopped. In the timer handler show the tip window.

···

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