16.9 Three scale widgets


The interface:


The code:


scale .red -label Red -from 0 -to 255 -length 10c \
                -orient horizontal -command newColor
scale .green -label Green -from 0 -to 255 -length 10c \
                -orient horizontal -command newColor
scale .blue -label Blue -from 0 -to 255 -length 10c \
                -orient horizontal -command newColor
frame .sample -height 1.5c -width 6c
pack .red .green .blue -side top
pack .sample -side bottom -pady 2m
proc newColor value {
        set color [format #%02x%02x%02x [.red get] [.green get] \
                        [.blue get]]
        .sample config -background $color
}



Back to Book Examples page

Back to Tcl/Tk page