I'd like to change the text & colour of text of my label depending on radiobutton choice. So far I have this code;
label $f0a.lbOPTION -text "Watts / FTP%" -font {Arial 10 bold} -bg white -fg #d000d0
radiobutton $f0a.rb00 -text "Watt" -var POWsel -value 1 -font {Arial 8 bold} -bg white -fg red
radiobutton $f0a.rb01 -text "FTP%" -var POWsel -value 0 -font {Arial 8 bold} -bg white -fg blue
set POWsel 1
I tried adding a command to the radiobuttons, but have obviously got it wrong. I assume I need to add a -command to the 2 radiobuttons and proc that then changes the label text & colour. (I assume I'll need to change the label from -text to -textvar)?
Any help much appreciated.
added this to the radio buttons:
-command [list togglePwr ::POWsel $f0a.$f0a.lbOPTION]
##-----------------------------------------------------------------------------
proc togglePwr {label } {
if {[set $radiobutton]} {
$label configure -text "Watts" -bg white -fg red
} else {
$label configure -text "FTP%" -bg white -fg blue
}
}
##-----------------------------------------------------------------------------