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 / spinner < prev    next >
Encoding:
Text File  |  2001-10-22  |  767 b   |  29 lines

  1. # ----------------------------------------------------------------------
  2. #  DEMO: spinner in [incr Widgets]
  3. # ----------------------------------------------------------------------
  4. package require Iwidgets 4.0
  5.  
  6. option add *textBackground seashell
  7.  
  8. proc spinMonth {win step} {
  9.     set months {
  10.         January February March April
  11.         May June July August September
  12.         October November December
  13.     }
  14.  
  15.     set index [expr [lsearch $months [$win get]] + $step]
  16.  
  17.     if {$index < 0} {set index 11}
  18.     if {$index > 11} {set index 0}
  19.  
  20.     $win delete 0 end
  21.     $win insert 0 [lindex $months $index]
  22. }
  23.  
  24. iwidgets::spinner .sm -labeltext "Month:" -width 10 -fixed 10 \
  25.     -decrement {spinMonth .sm -1} -increment {spinMonth .sm 1}
  26.  
  27. pack .sm
  28. .sm insert 0 "January"
  29.