0

I want tkinter.Entry not to echo the inputted characters like in linux shell's read -s command.

Here's my code. But I couldn't figure out how to hide inputted characters in tkinter.Entry() object.

import tkinter

window = tkinter.Tk()
password_entry = tkinter.Entry(show="")
password_entry.pack()
window.mainloop()

What I wanna achieve is something like that:

$ sudo useradd test
$ sudo passwd test
Enter new UNIX password: 
Enter new UNIX password: 
passwd: password updated successfully

It accepts the characters but it will not echo out to the terminal.

How to do that?

c_c
  • 1
  • 3

1 Answers1

0

An empty string resets it to default value, which is why you see the characters as normal. Setting it to space should work as you want, but it'll still move the cursor equal to the width of the password.

password_entry = tkinter.Entry(show=" ")
shriakhilc
  • 2,922
  • 2
  • 12
  • 17
  • Thank you for your suggestion. When I was testing the show parameter I realized '/t' and '/n' are valid for it. In the same sense I would like to try '\b' which is for backspace. password_entry = tkinter.Entry(show='\b') Unfortunately it doesn't work. So I think your answer currently is the most ideal one. – c_c Dec 29 '21 at 06:22