> >> The command in your version would be Tkx::style(...), but 
> note that 
> >> will need to be corrected when you upgrade Perl to 
> >> Tkx::ttk__style(...).
> >>
> >> Jeff
> >>
> > What goes in the parens?  I tried:
> >      Tkx::style("TEntry", -font =>  "courier 10"); But I 
> get an error.  
> > The following does not generate an error, and it works for 
> the button, 
> > but not for the entry:
> >      Tkx::style_configure("TButton", -font =>  "courier 10");
> >      Tkx::style_configure("TEntry", -font =>  "courier 10");
> 
> The latter command style is correct, but for -font, that is a 
> style element for buttons but remains a regular option for 
> ttk::entry, so just create the entry with -font.
> 
> Jeff
> 
How does one know that -font is a style element for buttons and not for
an entry?
If I want to change the font in an entry after it has been created, how
do I do that?

I didn't realize that there were differences like this.  So, back to my
original problem, how do background colors work for an entry?  How can I
change the color on an individual entry widget?

Font and colors for the entry widgets in the following don't change.
How do I change them?

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

my $mw = Tkx::widget->new(".");

my $text1 = "entry widget 1";
my $text2 = "2nd entry widget";

my $entry1 = $mw->new_ttk__entry(-width => 20, -textvariable =>
\$text1);
$entry1->configure(-font => "courier 24", -background => "blue");
$entry1->g_grid(-column => 0, -row => 0, -sticky => 'w');

my $entry2 = $mw->new_ttk__entry(-width => 20,
                                 -textvariable => \$text2,
                                 -style => "Dss.TEntry",
                                 -background => "aquamarine");
$entry2->configure(-font => "helvetica 24 bold");
$entry2->g_grid(-column => 0, -row => 1, -sticky => 'w');

my $button = $mw->new_ttk__button(-text => "Push Me");
$button->configure(-command => sub {exit;});
$button->g_grid(-column => 0, -row => 2);

Tkx::style_theme_use("alt");
Tkx::style_configure("TButton", -font => "helvetica 24");
Tkx::style_configure("TEntry", -background => "green", -font => "Courier
10 bold");
Tkx::style_configure("Dss.TEntry", -background => "red", -font =>
"Courier 10");

Tkx::after(3000, sub { AfterDelay(); });

Tkx::MainLoop();


sub AfterDelay
{
    $text2 = "in AfterDelay";
    $button->configure(-text => "Red?");
    Tkx::style_configure("TButton", -font => "helvetica 14 bold");
    Tkx::style_configure("TButton", -background => "red");
    Tkx::style_configure("TEntry", -background => "red");   # does
nothing?
    Tkx::after(3000, sub { AfterDelay2(); });
}

sub AfterDelay2
{
    $text2 = "in AfterDelay2";
    $button->configure(-text => "Done");
    Tkx::style_configure("TButton", -background => "green");
    #Tkx::style_map("TEntry",
    #                -background => ["disabled" => "red", "active" =>
"blue"],
    #                -foreground => ["disabled" => "yellow", "active" =>
"green"]);
    Tkx::style_configure("TEntry", -background => "green");
    Tkx::style("TEntry", -background => "green");
    Tkx::style("Dss.TEntry", -background => "yellow");
}

-- dss

Reply via email to