I think it's because you need to change:
my $button1 = $mw->Button(-text => "18-Letters", -command => sub {print OUTFILE "18L\n", back +ground => "yellow"})->pack(-side =>"top");
to this:
my $button1 = $mw->Button(-text => "18-Letters", -command => sub {print OUTFILE "18L\n" }, -background => "yellow"})->pack(-side =>"top +");
I don't use Tk or Tkx, but it seems to me that:
sub { print OUTFILE "18L\n", background => "yellow" }
Can't possibly do what you're expecting. The print statement doesn't know anything about colors. In fact, the code is essentially equal to:
sub { print OUTFILE "18L\n", "background", "yellow" }
So if you look at the file you're printing to, I'd expect you'll see some unexpected "backgroundyellow" strings in there.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Change button color with Tk
by roboticus
in thread Change button color with Tk
by PerlCowboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |