godatguitar
Programmer
Hi
I have started a new thread for this as I wasnt getting much of a reply in a different one - Hope you dont mind:
Here is the code for a button I have made, that will export the variable $result to an external file..... :
button $f.b -text "Submit Answers" -command {
set mark 0
# if the correct answer is chosen
if {$q1 == "0"} {incr mark}
if {$q2 == "1"} {incr mark}
if {$q3 == "2"} {incr mark}
set done 1
set result [expr {$mark * 100/3 }]
set fileId [open tmplgr "a"]
puts -nonewline $fileId "1"
puts $fileId $result
close $fileId
}
I need to disable the button once it has been pressed, and I need it to continue to do the rest of my code that is outside of a proc for various reasons:
ScrollableFrame .workspace
pack .workspace -expand yes -fill both
# Put the questions into the frame
Header .workspace.c.contents
Question .workspace.c.contents
Question1 .workspace.c.contents
Question2 .workspace.c.contents
Question3 .workspace.c.contents
Footer .workspace.c.contents
tkwait variable done
set q1 0
set q2 1
set q3 2
label .r -text "Your Result is $mark out of 3" -fg red
label .l -text "The Correct answers Have been selected for your reference."
pack .r -padx 0 -pady 0 -anchor n
pack .l -padx 0 -pady 0 -anchor n
#END OF PROGRAM
However, it only disables the button when I try and do this. Basically, I wanted to disable the submit button inside its -command { } , but I am unsure of how to do this.
Anyone got any ideas? I would luv to hear them.. Thanks
Paul
I have started a new thread for this as I wasnt getting much of a reply in a different one - Hope you dont mind:
Here is the code for a button I have made, that will export the variable $result to an external file..... :
button $f.b -text "Submit Answers" -command {
set mark 0
# if the correct answer is chosen
if {$q1 == "0"} {incr mark}
if {$q2 == "1"} {incr mark}
if {$q3 == "2"} {incr mark}
set done 1
set result [expr {$mark * 100/3 }]
set fileId [open tmplgr "a"]
puts -nonewline $fileId "1"
puts $fileId $result
close $fileId
}
I need to disable the button once it has been pressed, and I need it to continue to do the rest of my code that is outside of a proc for various reasons:
ScrollableFrame .workspace
pack .workspace -expand yes -fill both
# Put the questions into the frame
Header .workspace.c.contents
Question .workspace.c.contents
Question1 .workspace.c.contents
Question2 .workspace.c.contents
Question3 .workspace.c.contents
Footer .workspace.c.contents
tkwait variable done
set q1 0
set q2 1
set q3 2
label .r -text "Your Result is $mark out of 3" -fg red
label .l -text "The Correct answers Have been selected for your reference."
pack .r -padx 0 -pady 0 -anchor n
pack .l -padx 0 -pady 0 -anchor n
#END OF PROGRAM
However, it only disables the button when I try and do this. Basically, I wanted to disable the submit button inside its -command { } , but I am unsure of how to do this.
Anyone got any ideas? I would luv to hear them.. Thanks
Paul