Fixing bug in Debug with ToolTip for wire value disappearing on Windows
authorlaurent
Wed, 21 Dec 2011 19:38:26 +0100
changeset 612 fdb9501e5cc8
parent 611 9d24fa46523f
child 613 c487c54c1cfe
Fixing bug in Debug with ToolTip for wire value disappearing on Windows
graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py	Tue Dec 20 23:37:26 2011 +0100
+++ b/graphics/GraphicCommons.py	Wed Dec 21 19:38:26 2011 +0100
@@ -507,9 +507,11 @@
 
 class ToolTip(wx.PopupWindow):
     
-    # Create a rubberband by indicated on which window it must be drawn
     def __init__(self, parent, tip):
         wx.PopupWindow.__init__(self, parent)
+        
+        self.CurrentPosition = wx.Point(0, 0)
+        
         self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
         self.SetTip(tip)
         
@@ -518,12 +520,16 @@
     def SetTip(self, tip):
         self.Tip = tip
         wx.CallAfter(self.RefreshTip)
-        
+    
+    def MoveToolTip(self, pos):
+        self.CurrentPosition = pos
+        self.SetPosition(pos)
+    
     def RefreshTip(self):
         if self:
-            dc = wx.ClientDC(self)
-            w, h = dc.GetTextExtent(self.Tip)
+            w, h = self.GetTextExtent(self.Tip)
             self.SetSize(wx.Size(w + 4, h + 4))
+            self.SetPosition(self.CurrentPosition)
             self.Refresh()
         
     def OnPaint(self, event):
@@ -1807,12 +1813,12 @@
             else:
                 computed_value = str(self.Value)
             self.ToolTip = ToolTip(self.Parent, computed_value)
-            self.ToolTip.SetPosition(pos)
+            self.ToolTip.MoveToolTip(pos)
             self.ToolTip.Show()
     
     def MoveToolTip(self, pos):
         if self.ToolTip is not None:
-            self.ToolTip.SetPosition(pos)
+            self.ToolTip.MoveToolTip(pos)
     
     def ClearToolTip(self):
         if self.ToolTip is not None: