Unfortunately, the show
attribute of the Entry
widget doesn't work that way: as you've noticed, it simply specifies a single character to show instead of what characters were typed.
To get the effect you want, you'll need to intercept key presses on the Entry
widget, and translate them, then. You have to be careful, though, to only mutate keys you really want, and leave others (notably, Return, Delete, arrow keys, etc). We can do this by binding a callback to all key press events on the Entry box:
self.Password.bind("<Key>", callback)
where callback()
is defined to call your random function if it's an ascii letter (which means numbers pass through unmodified), insert the random character, and then return the special break
string constant to indicate that no more processing of this event is to happen):
def callback(event):
if event.char in string.ascii_letters:
event.widget.insert(END, random_char())
return "break"