#!/bin/sh
# bttn_chk_rado.tcl \
exec tclsh "$0" ${1+"$@"}
proc push_button {} {
global selection
tk_messageBox -message "$selection!" -type ok
}
proc push_button2 { } {
global selection2
set selection {}
foreach value [array name selection2] {
if {$selection2($value)!= 0} {
set selection "$selection and $selection2($value)"
}
}
tk_messageBox -message "you chose $selection!" -type ok
}
proc toggle { } {
.chk1 toggle
}
set selection 0
frame .textarea -background red -borderwidth 2 -relief flat
for {set i 1} {$i <= 10} {incr i} {
radiobutton .rad$i -text "choice #$i" -variable selection -value "choice is $i"
pack .rad$i -in .textarea
}
frame .frmchk -background green -borderwidth 5 -relief groove
for {set i 1} {$i <= 10} {incr i} {
checkbutton .chk$i -text "choice #$i" -variable selection2($i) -onvalue "$i" -offvalue 0
pack .chk$i -in .frmchk
}
button .but -text "show selection radio button" -command "push_button"
button .but2 -text "show selection checkbox" -command "push_button2"
button .but3 -text "toggle the selection of checkbox #1" -command "toggle"
pack .textarea
pack .frmchk
pack .but
pack .but2
pack .but3
# bttn_chk_rado.tcl \
exec tclsh "$0" ${1+"$@"}
proc push_button {} {
global selection
tk_messageBox -message "$selection!" -type ok
}
proc push_button2 { } {
global selection2
set selection {}
foreach value [array name selection2] {
if {$selection2($value)!= 0} {
set selection "$selection and $selection2($value)"
}
}
tk_messageBox -message "you chose $selection!" -type ok
}
proc toggle { } {
.chk1 toggle
}
set selection 0
frame .textarea -background red -borderwidth 2 -relief flat
for {set i 1} {$i <= 10} {incr i} {
radiobutton .rad$i -text "choice #$i" -variable selection -value "choice is $i"
pack .rad$i -in .textarea
}
frame .frmchk -background green -borderwidth 5 -relief groove
for {set i 1} {$i <= 10} {incr i} {
checkbutton .chk$i -text "choice #$i" -variable selection2($i) -onvalue "$i" -offvalue 0
pack .chk$i -in .frmchk
}
button .but -text "show selection radio button" -command "push_button"
button .but2 -text "show selection checkbox" -command "push_button2"
button .but3 -text "toggle the selection of checkbox #1" -command "toggle"
pack .textarea
pack .frmchk
pack .but
pack .but2
pack .but3
1. To display text message dialog box command used here is: "tk_messageBox", used in procedure named "proc push_button".
ReplyDelete2. To toggle any check box selection (here chk1) "toggle" key word is used