Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get entry field as a password (*) in notebook tab pygtk

I have used gtk.Notebook() in my script, In notebook tab I have given 2 text fields username and password but problem is that the entry field does not behave as password field, it is showing character. so I want if i type password it should be confidential jsut like as (*).

This is code which i have used

    entry = gtk.Entry()
    entry.set_invisible_char("*")
    entry.set_size_request(100, 75)
    entry.show ()

    label = gtk.Label("Add page")
    notebook.insert_page(entry, label, 2)

Now anyone tell me how to do that.

Thanks in advance...

like image 559
Ashish Jain Avatar asked Nov 19 '25 20:11

Ashish Jain


1 Answers

Gtk Entry documentation:

gtk_entry_set_visibility() sets whether the contents of the entry are visible or not. When visibility is set to FALSE, characters are displayed as the invisible char, and will also appear that way when the text in the entry widget is copied elsewhere.

For python that should be Entry.set_visibility(False).

Also, you don't need to set the invisible character: GTK+ will do it's best to pick a good character for the font in question (typically '*').

like image 62
Jussi Kukkonen Avatar answered Nov 21 '25 08:11

Jussi Kukkonen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!