home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / demos / IWidgets / entryfield < prev    next >
Encoding:
Text File  |  2001-10-22  |  1.0 KB  |  34 lines

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