indigosplinter has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I'm trying to add a set of radiobuttons (related, selecting the value of a single variable) to an application in Tk with a consistent color scheme. I have the following code:
$b_frame->RadiobuttonGroup( -list => [qw( stuff... )], -bg => "lightslategray", -fg => "white", -selectcolor => "white", -highlightcolor => "lightslategray", -orientation => 'vertical', -variable => \$ss_default )->pack();
Unfortunately, the -bg and -fg keys only apply to the boarder around the labels, not the labels themselves. I'm getting a big block of text/radio buttons with the text labels in OS default colors. It's probably something simple, but... a little help here?

Replies are listed 'Best First'.
Re: Colorizing the labels in Tk::RadiobuttonGroup
by shmem (Chancellor) on Jun 28, 2006 at 14:14 UTC
    Assuming
    my $rg = $b_frame->RadiobuttonGroup(-list => [qw( stuff)])->pack();
    then
    $rg->{'SubWidget'}->{'stuff'}->configure(-background => 'pink');
    should do. The direct dereferencing of the $rg object hash is ugly, though. Find out if there's a method ("use the source, luke" :-)

    --shmem.

    Update:

    The manual page states:

    DESCRIPTION Displays a set of related radiobuttones with a frame in vertical or + hori- zontal orientation. All radiobuttones are advertised with the names given in the -list option. Any additional options which are given to this widget are applied t +o all of the radiobuttons it manages.

    This is not the case, so I call that a Bug or at least an inconsistency between object behaviour and manual page. You should report that to the author.

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Colorizing the labels in Tk::RadiobuttonGroup
by johngg (Canon) on Jun 28, 2006 at 13:21 UTC
    The script below has a scheme for button colouring that may give you some help.

    The code is a bit old and creaky but the Tk stuff should be relevant to your problem. I hope it is of use.

    Cheers,

    JohnGG

      That does help, thanks. Breaking up my list into individual radiobuttons did the trick. It seems that the 'radiobuttongroup' function doesn't support the label colors the way the stand-alone one does. Too bad, but its just more lines of code. A lot more.