1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/bin/sh
# ----------------------------------------------------------------------
# DEMO: entryfield in [incr Widgets]
# ----------------------------------------------------------------------
#\
exec itkwish -f "$0" ${1+"$@"}
package require -exact Iwidgets 2.2
# itkwish interprets the rest...
# ----------------------------------------------------------------------
option add *textBackground seashell
. configure -background white
iwidgets::entryfield .login -labeltext "Login:" -labelpos nw \
-command { focus [.passwd component entry] }
pack .login -padx 4 -pady 4
iwidgets::entryfield .passwd -labeltext "Password:" -labelpos nw -show "\267" \
-command { focus [.phone component entry] }
pack .passwd -padx 4 -pady 4
iwidgets::entryfield .phone -labeltext "Phone:" -labelpos nw \
-command { focus [.login component entry] } \
-validate {check_phonenum %W "%c"}
pack .phone -padx 4 -pady 4
proc check_phonenum {entry char} {
set current [$entry get]
set len [string length $current]
if {$len == 3 || $len == 7} {
$entry delete 0 end
$entry insert 0 "$current-"
}
if {$len < 12 && [string match {[0-9]} $char]} {
return 1
}
return 0
}
|