hmmeeranrizv...@gmail.com wrote: > Hello Guys, > Here i am creating a entry box with some text,i need to hide the text when > i click on it. Here is my code > > from Tkinter import * > obj = Tk() > b = Entry(obj,width=100) > b.insert(0,"Enter the value to search") > b.pack() > mainloop()
You need to bind a callback function to a mouse event: import Tkinter as tk def clear_search(event): search.delete(0, tk.END) root = tk.Tk() search = tk.Entry(root, width=100) search.insert(0, "Enter the value to search") search.pack() search.bind("<Button-1>", clear_search) root.mainloop() This will always clear the Entry; you probably want to check if it contains the initial message first to avoid that the user accidentally loses input. -- https://mail.python.org/mailman/listinfo/python-list