Re: radio/checkbuttons - get select state



First off sounds like a really bad GUI design (IMHO you should not have -indicatoron 0, and change the background). But given that...

Your call back is on the correct lines, you just need to in your switch use the -variable and either -value or -onvalue and -offvalue in cget.

miss.cross09@xxxxxxxxx wrote:
hi,

sorry, maybe my question wasn't detailed enough.

info at the beginning: using tk 8.4 (so unfortunately no "instate"
command i guess)

throuout the whole application every single button has a binding Enter
and Leave with %W as a parameter.
indepented to the class type of the button.

the enter callback then sets the bg of the button to a nice highlight
color. which works fine.

but in the leave callback i will have to set the bg back to the
default bg OR the select bg of the buttons.
i cannot use the cget -variable and then check the value, because it
can be different as i am using on and offvalues!
additional info: the check and radio buttons are defined with -
indicatoron 0

the bg and the selectcolor of the radiobuttons is different to the bg
and selectcolors of the checkbutton.
so to be able to set it back to the correct color with mouse leave, i
will have to know, if the button is pushed or not.

in the leave callback there would be something like:

set type [winfo class $w]

switch -exact $type {

Button {
$w config -bg grey
}
Checkbutton {
--- IF SELECTED
$w config -bg yellow
--- ELSE
$w config -bg whatever
}
Radiobutton {
--- IF SELECTED
$w config -bg green
--- ELSE
$w config -bg blue
}

}


or is there any other possibility? maybe there is a much easier
solution for this?

sorry for typo, if happenend. its late at night here ;-)

thx again


--
+------------------------------------------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.


Quantcast