Salome HOME
PN : pour visualisation des geométries + correction de bug
[tools/eficas.git] / Editeur / tooltip.py
index 18d03d582ec38c91a85312ea762a77337bf6beb5..18fbabb5e497536d52b9a18cd75b88029109bc2d 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 #            CONFIGURATION MANAGEMENT OF EDF VERSION
 # ======================================================================
 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
 """
 
 import Tkinter
+import types
+
+def destruct(obj):
+    # assist in breaking circular references
+    if obj is not None:
+        assert type(obj) is types.InstanceType
+        for k in obj.__dict__.keys():
+            obj.__dict__[k] = None
+            ##del obj.__dict__[k]
+
+def after(widget, ms, func, *args):
+    timer = apply(widget.after, (ms, func) + args)
+    command = widget._tclCommands[-1]
+    return (timer, command, widget)
+
+def after_cancel(t):
+    if t is not None:
+        t[2].after_cancel(t[0])
+        try:
+            t[2].deletecommand(t[1])
+        except Tkinter.TclError:
+            pass
 
 class TOOLTIP:
-    def __init__(self,widget):
+    def __init__(self,widget,text=None):
         self.widget=widget
-        self.text = None
+        self.text = text
         self.timer = None
         self.tooltip = None
         self.label = None
@@ -95,3 +118,10 @@ class TOOLTIP:
         self.tooltip.wm_geometry("%+d%+d" % (x, y))
         self.tooltip.wm_deiconify()
 
+if __name__ == "__main__":
+   root=Tkinter.Tk()
+   label = Tkinter.Label(root, text="coucou")
+   label.pack()
+   tp=TOOLTIP(label,"texte d'aide")
+   root.mainloop()
+