Python Gtk.Entry Placeholder Text

I have a login window with two gtk.Entry objects, one for the username, one for the password. How can I add a Ghosttext to the record, so the "Username" is written in the record, but if you click inside the text, it will disappear.

+6
source share
2 answers

Starting with Gtk + 3.2, you can set placeholder text .

entry = Gtk.Entry() entry.set_placeholder_text("I am a placeholder") 
+10
source

I found an example where .set_text () and .select_region () are used to pre-select text, so it is deleted when the user starts typing.

This does not work if you have several Gtk.Entry fields, because only one can be selected at a time. I believe that you need to use a signal to delete text when you press the "Enter" field.

If you cannot figure it out, add a few tags.

+1
source

Source: https://habr.com/ru/post/923013/


All Articles