Not sure of the best way, but the following might help for some widgets.
I'm using an old version of Perl (v5.8.8).

use strict;
use Tkx;
Tkx::package_require("tile");
Tkx::package_require("style");
Tkx::package_require("BWidget");

my $dogs = "Akita Bulldog Chihuahua Doberman EnglishFoxhound FoxTerrier";
my $entry_text  = "Entry Text";
my $button_text  = "Button Text";
my $radio_text = "Radio Text";
my $combo_text = "Combo Text";

my $mw = Tkx::widget->new(".");
my $sw = $mw->new_ScrolledWindow(-managed => 0);
my $sf = $sw->new_ScrollableFrame();
my $subf = Tkx::widget->new($sf->getframe());
$subf->m_configure(-background => "darkgray");
$sw->setwidget($sf);
$sw->g_grid(-row => 0, -column => 0, -sticky => "nsew");

Tkx::grid(rowconfigure => $mw, 0, -weight => 1);
Tkx::grid(columnconfigure => $mw, 0, -weight => 1);

MakeLabel("ttk__", 1, 1);
my $l = $subf->new_label(-width => 10, -background =>
'darkgray')->g_grid(-column => 4, -row => 1);
MakeLabel("",      1, 5);
MakeEntry("ttk__", 2, 1);
MakeEntry("",      2, 5);
MakeButton("ttk__", 3, 1);
MakeButton("",      3, 5);
MakeListbox("ttk__", 4, 1);
MakeListbox("",      4, 5);
MakeRadioButton("ttk__", 5, 1);
MakeRadioButton("",      5, 5);
MakeComboBox("ttk__", 6, 1);
MakeComboBox("",      6, 5);

sub MakeLabel
{
    my ($which, $row, $col) = @_;
    my ($widget);
    $widget = $subf->new_ttk__label(-text => "Label with ttk__")    if
$which eq "ttk__";
    $widget = $subf->new_label(-text => "plain Label")              if
$which ne "ttk__";
    $widget->configure(-background => 'darkgray');
    $widget->g_grid(-column => $col, -row => $row, -sticky => 'w');
    my $b = $subf->new_ttk__button(-text => "Color", -command => sub
        { $widget->configure(-foreground => "yellow", -background =>
"blue"); });
    $b->g_grid(-column => ($col + 2), -row => $row, -sticky => 'w');
}

sub MakeEntry
{
    my ($which, $row, $col) = @_;
    my ($widget);
    $widget = $subf->new_ttk__entry(-width => 30, -textvariable =>
\$entry_text)    if $which eq "ttk__";
    $widget = $subf->new_entry(-width => 30, -textvariable =>
\$entry_text)         if $which ne "ttk__";
    $widget->g_grid(-column => $col, -row => $row, -sticky => 'w');
    my $b = $subf->new_ttk__button(-text => "Color", -command => sub
        { $widget->configure(-foreground => "green", -background => "red");
});
    $b->g_grid(-column => ($col + 2), -row => $row, -sticky => 'w');
}

sub MakeButton
{
    my ($which, $row, $col) = @_;
    my ($widget);
    $widget = $subf->new_ttk__button(-text => $button_text, -command => sub
{ print "command\n"; }) if $which eq "ttk__";
    $widget = $subf->new_button(-text => $button_text, -command => sub {
print "command\n"; })      if $which ne "ttk__";
    $widget->g_grid(-column => $col, -row => $row, -sticky => 'w');
    my $b = $subf->new_ttk__button(-text => "Color", -command => sub
        { $widget->configure(-foreground => "blue", -background =>
"aquamarine"); $widget->configure(-text => "Changed");});
    $b->g_grid(-column => ($col + 2), -row => $row, -sticky => 'w');
}

sub MakeListbox
{
    my ($which, $row, $col) = @_;
    my ($widget);
    #$widget = $subf->new_ttk__listbox(-width => 30, -listvariable =>
\$dogs)    if $which eq "ttk__";
    return  if $which eq "ttk__";
    $widget = $subf->new_listbox(-width => 30, -listvariable =>
\$dogs)         if $which ne "ttk__";
    my $scroll = $subf->new_ttk__scrollbar(-orient => 'vertical', -command
=> [$widget, 'yview']);
    $widget->configure(-height => 3);
    $widget->configure(-yscrollcommand => [$scroll, 'set']);
    $widget->g_grid(-column => $col, -row => $row, -sticky => 'w');
    $scroll->g_grid(-column => $col+1, -row => $row, -sticky => "w");
    my $b = $subf->new_ttk__button(-text => "Color", -command => sub {
        $widget->configure(-foreground => "yellow", -background => "green");
        $widget->configure(-selectforeground => "red", -highlightbackground
=> "#800000");
        $widget->itemconfigure(0, -foreground => "blue", -background =>
"#000080");
        #$widget->configure(-highlightforeground => "red",
-highlightbackground => "blue");
    });
    $b->g_grid(-column => ($col + 2), -row => $row, -sticky => 'w');
}

sub MakeRadioButton
{
    my ($which, $row, $col) = @_;
    my ($widget);
    $widget = $subf->new_ttk__checkbutton(-text => 'Yes', -variable =>
\$radio_text, -onvalue => 1) if $which eq "ttk__";
    $widget = $subf->new_checkbutton(-text => 'Yes', -variable =>
\$radio_text, -onvalue => 1)      if $which ne "ttk__";
    $widget->configure(-command => sub { print "command\n"; });
    $widget->g_grid(-column => $col, -row => $row, -sticky => 'w');
    my $b = $subf->new_ttk__button(-text => "Color", -command => sub
        { $widget->configure(-foreground => "red", -background => "yellow");
});
    $b->g_grid(-column => ($col + 2), -row => $row, -sticky => 'w');
}

sub MakeComboBox
{
    my ($which, $row, $col) = @_;
    my ($widget);
    $widget = $subf->new_ttk__combobox(-textvariable => \$combo_text)  if
$which eq "ttk__";
    return  if $which ne "ttk__";
    # $widget = $subf->new_combobox(-textvariable => \$combo_text)        if
$which ne "ttk__";
    $widget->configure(-values => $dogs);
    $widget->g_bind("<<ComboboxSelected>>", sub { print "combo command\n";
});
    $widget->g_grid(-column => $col, -row => $row, -sticky => 'w');
    my $b = $subf->new_ttk__button(-text => "Color", -command => sub
        { $widget->configure(-foreground => "red", -background =>
"#800000"); });
    $b->g_grid(-column => ($col + 2), -row => $row, -sticky => 'w');
}

Tkx::MainLoop;


Dave


On Wed, Jul 6, 2011 at 4:15 PM, gary sachs <conversecoroll...@yahoo.com>wrote:

> AS Perl V5.12
> Tkx (Tcl 8.5.9)
> Windows XP
>
> Is there anyway to alter the background colors of the ttk_entry and
> ttk_buttons? If so, how?
>
> thanks,
> gary
>

Reply via email to