How to display text in the window when the cursor is placed over the button.
I have below code, when put cursor over the button "Ok" it has to show text as "Check details filled before pressing Ok".
import Tkinter
class Example(Tkinter.Frame):
def __init__(self, *args, **kwargs):
Tkinter.Frame.__init__(self, *args, **kwargs)
self.l1 = Tkinter.Label(self, text="Enter name")
self.l2 = Tkinter.Label(self, text="", width=40)
self.l1.pack(side="top")
self.l2.pack(side="top", fill="x")
self.b1 = Tkinter.Button(root, text="Ok")
self.b1.bind("<Enter>", self.on_enter)
self.b1.bind("<Leave>", self.on_leave)
self.b1.pack()
def on_enter(self, event):
self.l2.configure(text="Check details filled before pressing Ok")
def on_leave(self, enter):
self.l2.configure(text="")
if __name__ == "__main__":
root = Tkinter.Tk()
Example(root).pack(side="top", fill="both", expand="true")
root.mainloop()
The same code works fine if I write for display text when cursor is placed over label l1. Is there any other way to proceed for displaying when cursor placed on button or any modifications??