Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Gtk.Entry placeholder text

i have a login-window with two gtk.Entry objects, one for username, one for password. How can i add some Ghosttext to the Entry, so there is written "Username" in the Entry but if you click inside the text dissapears.

like image 871
HappyHacking Avatar asked Aug 16 '12 07:08

HappyHacking


Video Answer


2 Answers

Starting with Gtk+ 3.2 it's possible to set placeholder text.

entry = Gtk.Entry()
entry.set_placeholder_text("I am a placeholder")
like image 92
plaes Avatar answered Oct 11 '22 13:10

plaes


I've found an example where .set_text() and .select_region() are used to preselect the text, so it is deleted when the user starts to type.

This doesn't seem to work if you have more than one Gtk.Entry fields, because only one can be selected at a time. I reckon you have to use a signal to delete the text when the Entry field is clicked.

If you can't figure it out, add some labels.

like image 42
eminor Avatar answered Oct 11 '22 14:10

eminor