http://qs1969.pair.com?node_id=913492

ZJ.Mike.2009 has asked for the wisdom of the Perl Monks concerning the following question:

A radiobutton is a widget that has a textual string and a circle. In the following code, without the mouse hovering on the radiobutton, the background colors of the circle and the text are white and khaki separately. With the mouse hovering, the background colors of the circle and the text are both khaki. Is there a way to make the background color of the circle stay white? Or is this some kind of compatibility issue with Tk running on Windows (I'm running Tk 804.29 with ActivePerl 5.12.1 on Win XP)? A WxPerl radiobutton does not seem to give me this problem.
use strict; use warnings; use Tk; my $mw = MainWindow -> new(); my $frame = $mw -> Frame()-> pack( ); my $id = 0; my $bg_color = 'khaki'; my $radio_button1 = $frame -> Radiobutton ( -text => 'RadioButton1', -value =>0, -variable => \$id, -bg => $bg_color, -activebackground => $bg_color, -activeforeground => 'red', ) -> pack (); my $radio_button2 = $frame -> Radiobutton ( -text => 'RadioButton1', -value =>1, -variable => \$id, -bg => $bg_color, -activebackground => $bg_color, -activeforeground => 'red', ) -> pack (); MainLoop;
  • Comment on Does the active background color of the circle of a Tk radio button have to be the same as that of the textual string?
  • Download Code

Replies are listed 'Best First'.
Re: Does the active background color of the circle of a Tk radio button have to be the same as that of the textual string?
by zentara (Archbishop) on Jul 09, 2011 at 14:52 UTC
Re: Does the active background color of the circle of a Tk radio button have to be the same as that of the textual string?
by Anonymous Monk on Jul 09, 2011 at 14:39 UTC

    Is there a way to make the background color of the circle stay white?

    Sure, create your own radiobutton widget, one made of two radio buttons, one with activecolor specified, one without -- check cpan, somebody might have already done it

    Or is this some kind of compatibility issue with Tk running on Windows (I'm running Tk 804.29 with ActivePerl 5.12.1 on Win XP)?

    I doubt it, but I can't confirm (I only have win32)

    A WxPerl radiobutton does not seem to give me this problem.

    Not exactly relevant :) wxRadioButton doesn't have an activecolor option either, and not being able to set color for the check/radio is considered a bug #10137 ([MSW-XP] wxRadioButton::SetForegroundColour doesn’t work) – wxWidgets