|
Spinner
Spinners constitute a set of widgets which provide EntryField functionality combined with increment and decrement arrow buttons which may be oriented in a vertical, top and bottom, fashion or in a horizontal, side by side, manner. A value may be entered into the entry area explicitly or the buttons may be pressed which cycle up and down through the choices. This latter behavior is one of spinning.
For further information, see the Spinner
manpage
Components: downarrow entry hull label uparrow
|
wm title . "Spinner Example"
set months {Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec}
##
## Helper procs
##
proc blockInput {} {return 0}
proc spinMonth {direction} {
global months
set index [expr [lsearch $months [.sm get]] + $direction]
if {$index < 0} {set index 11}
if {$index > 11} {set index 0}
.sm delete 0 end
.sm insert 0 [lindex $months $index]
return
}
##=========================================================
## Create a spinner iwidget
##=========================================================
##
iwidgets::spinner .sm \
-labeltext "Enter Month : " \
-width 5 \
-fixed 3 \
-validate blockInput \
-decrement {spinMonth -1} \
-increment {spinMonth 1}
.sm insert 0 [clock format [clock seconds] -format "%b"]
pack .sm \
-padx 10 \
-pady 10
|
Download this sample code |
|