#!../expectk # Name: passwd.tk - entry widget that shows *'s # # Description: This example demonstrates the bindings to make an entry show # asterisks instead of the real characters - good for entering passwords. # # The actual password is maintained in the global variable "password". # # Author: Don Libes, NIST if {$tk_version >= 4} { puts "No need for this stuff. Instead use entry's -show flag." exit } set password {} entry .e -relief sunken -bd 4 pack .e focus .e proc backspace {w} { global password regexp (.*). $password dummy password dummy tk_entryBackspace $w tk_entrySeeCaret $w } bind .e {backspace %W} bind .e {backspace %W} bind .e {puts $password} bind .e { if {"%A" != ""} { %W insert insert * set password "[set password]%A" tk_entrySeeCaret %W } }