|
Checkbox
The Checkbox iwidget allows the user to organize related checkbuttons into a group. There are methods for adding, inserting, deleting, selecting, and deselecting checkbuttons by tag and index. Each checkbutton can have it's own attributes, either when the checkutton is added or by using the buttonconfigure public method.
For further information, see the Checkbox
manpage
Components: childsite hull label
|
wm title . "Checkbox Example"
##
## wrap in a dialog user interaction
##
iwidgets::dialog .d \
-title "Checkbox Example"
.d hide Help
.d hide Apply
.d buttonconfigure OK \
-text "Update"
set cs [.d childsite]
##=========================================================
## Create a checkbox iwidget
##=========================================================
##
iwidgets::checkbox $cs.cb \
-labeltext "Places Visited" \
-labelpos n
pack $cs.cb \
-fill both \
-expand true
##
## set some lists
##
set places [list australia england france germany spain hawaii tahiti]
lappend places venezuela argentina greece china japan new_zealand mexico
lappend places peru chile canada africa russia
set been_there [list england france germany spain hawaii venezuela argentina]
lappend been_there greece china japan mexico canada
##
## Add some checkbuttons
##
## Note that 'string totitle' is valid
## for tcl_version >= 8.1
##
foreach c [lsort $places] {
$cs.cb add $c \
-text [string totitle $c]
}
##
## Select some of the boxes
##
foreach c $been_there {
$cs.cb select $c
}
##
## activate the dialog
##
if {[.d activate]} {
puts "Updated"
}
|
Download this sample code |
|