Hide text in entry box when i click on it.(GUI using Tkinter in python)

Christian Gollwitzer auriocus at gmx.de
Wed Jan 25 14:12:15 EST 2017


Am 25.01.17 um 10:18 schrieb Peter Otten:
> hmmeeranrizvi18 at 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.

> search.bind("<Button-1>", clear_search)
>

This is the correct answer for a mouse click. The typical use case 
(disappearing placeholder) should also trigger, when somebody uses the 
tab key to set the focus to the window. This can be achieved by binding 
to the <FocusIn> event instead:

	search.bind("<FocusIn>", clear_search)

In addition, repeated clicking does not clear the text then.

	Christian



More information about the Python-list mailing list