Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbutton not setting value to variable?

Status
Not open for further replies.

mucklow

Programmer
May 22, 2001
40
US
For some reason, the checkbuttons as I have them set up below will not toggle the value of the variables assigned to them when checked/unchecked. Whats odd is this exact same code works in a different procedure but not this one, the variables keep and retain whatever the initial state of the checkbutton is set to. I tried adding and deleting global declarations for these variables but no change. These are contained in a procedure, $read2 $write2 and $exe2 are set up as either r,w,x, or "-" within the proc. I cut out some of the stuff going on inside the procedure here just to explain it simpler. In other words, if it reads $read2 as "r", then the "read" checkbutton lights up, but the variable i_read is now stuck on "r" and won't go back to "-", even if I uncheck it. What gives?

proc save_acl {file user} {

checkbutton $w.c1 -text "Read " -relief sunken -variable i_read -onvalue r -offvalue -
checkbutton $w.c2 -text "Write " -relief sunken -variable i_write -onvalue w -offvalue -
checkbutton $w.c3 -text "Execute" -relief sunken -variable i_exe -onvalue x -offvalue -

if {$read2=="r"} {
$w.c1 select}
if {$write2=="w"} {
$w.c2 select}
if {$exe2=="x"} {
$w.c3 select}

pack $w.c1 $w.c2 $w.c3 -side top

button $w.dismiss2 -text "Cancel" -command {destroy .single}

button $w.accept2 -text "Save changes" -command {save_acl2 $user $file $i_read $i_write $i_exe}

bind $w.accept2 <Return> {save_acl2 $user $file $i_read $i_write $i_exe}

bind $w.dismiss2 <Return> {destroy .single}

pack $w.dismiss2 $w.accept2 -side bottom -anchor s
}
 
Update to the above, I bound a command for a tkmessagebox to pop up each time I clicked the button to display the current value of the variable assigned to the button. The value is getting changed each time its clicked, but when I send the variable to another procedure it retains whatever the initial value was for the checkbutton. I've also tried

button $w.accept2 -text &quot;Save changes&quot; -command &quot;save_acl2 $user $file $i_read $i_write $i_exe&quot;

with the same result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top