I am implementing an entry and button with the following functionality. On clicking the button I will get a list of check buttons. After selecting check buttons they should get reflected in the entry. The following is my implementation. The one thing I don't like is passing the entry (.e
) to both get_values
and myok
. Is there a better solution to my problem ?
entry .e -width 15 -relief sunken
button .b -text "..." -command [list get_values .e]
pack .e .b -side left
proc get_values { entry } {
toplevel .values
checkbutton .values.c1 -text "C1" -variable c1
checkbutton .values.c2 -text "C2" -variable c2
button .values.ok -text "OK" -command [list myok $entry .values]
button .values.cancel -text "Cancel" -command [list mycancel .values]
pack .values.c1 .values.c2 -side top
pack .values.cancel .values.ok -side right
}
proc myok { entry warg } {
variable c1
variable c2
$entry delete 0 end
if { $c1 } {
$entry insert insert " "
$entry insert insert "c1"
}
if { $c2 } {
$entry insert insert " "
$entry insert insert "c2"
}
destroy $warg
}
proc mycancel { warg } {
destroy $warg
}