summaryrefslogtreecommitdiff
path: root/itcl/iwidgets/demos/spinner
blob: 703bfa1d7d7b08b744439e916d1cbbb297d7c745 (plain)
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
# ----------------------------------------------------------------------
#  DEMO: spinner in [incr Widgets]
# ----------------------------------------------------------------------
package require Iwidgets 4.0

option add *textBackground seashell

proc spinMonth {win step} {
    set months {
        January February March April
        May June July August September
        October November December
    }

    set index [expr [lsearch $months [$win get]] + $step]

    if {$index < 0} {set index 11}
    if {$index > 11} {set index 0}

    $win delete 0 end
    $win insert 0 [lindex $months $index]
}

iwidgets::spinner .sm -labeltext "Month:" -width 10 -fixed 10 \
    -decrement {spinMonth .sm -1} -increment {spinMonth .sm 1}

pack .sm
.sm insert 0 "January"