Version 2 of spinbox

Updated 2002-09-04 12:55:18

http://purl.org/tcl/home/man/tcl8.4/TkCmd/spinbox.htm


Pre-8.4 substitute: Here is a concoction of a 1-line high listbox with two tiny buttons, to approximate the effects of a spinbox:

 proc spinner {w args} {    
    set im(up) [image create bitmap -data "
 #define i_width 5
 #define i_height 3
 static char i_bits[] = {
    4,14,31
 }"]
 set im(dn) [image create bitmap -data "
 #define i_width 5
 #define i_height 3
 static char i_bits[] = {
    31,14,4
 }"]

    frame $w
    eval listbox $w.l -height 1 $args    
    frame $w.f
    button $w.f.1 -image $im(up) -width 10 -height 4 \
          -command [list $w.l yview scroll -1 unit]
    button $w.f.2 -image $im(dn) -width 10 -height 4 \
          -command [list $w.l yview scroll 1 unit]
    pack $w.f.1 $w.f.2
    pack $w.l $w.f -side left -fill y
    return $w.l
 } ;# RS

#-------------------------------- Testing:

 set testlist {foo bar grill room}
 spinner .x -listvar testlist -bg yellow
 pack .x

Tk syntax help - Arts and crafts of Tcl-Tk programming - Category Command