PerlCowboy has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use Tk; open(OUTFILE, '>>forecast.txt') or die "Cannot open forecast.txt: $!"; my $mw = MainWindow->new; $mw->geometry("150x700"); $mw->title("Multiple Windows Test"); my $button1 = $mw->Button(-text => "18-Letters", -command => sub {print OUTFILE "18L\n", back +ground => "yellow"})->pack(-side => "top"); my $button2 = $mw->Button(-text => "07-Orders", -command => sub {print OUTFILE "07O\n"})->pa +ck(-side => "top"); my $button3 = $mw->Button(-text => "36-Letters", -command => sub {print OUTFILE "36L\n"})->pa +ck(-side => "top"); my $button4 = $mw->Button(-text => "38-Letters", -command => sub {print OUTFILE "38L\n"})->pa +ck(-side => "top"); my $button5 = $mw->Button(-text => "11-Orders", -command => sub {print OUTFILE "11O\n"})->pa +ck(-side => "top"); my $button6 = $mw->Button(-text => "99-Letters", -command => sub {print OUTFILE "99L\n"})->pa +ck(-side => "top"); my $button7 = $mw->Button(-text => "21-Letters", -command => sub {print OUTFILE "21L\n"})->pa +ck(-side => "top"); my $button8 = $mw->Button(-text => "23-Letters", -command => sub {print OUTFILE "23L\n"})->pa +ck(-side => "top"); my $button9 = $mw->Button(-text => "Return to L&I", -command => sub {print OUTFILE "OOO\n"})->pa +ck(-side => "top"); my $button10 = $mw->Button(-text => "D1008235", -command => sub {print OUTFILE "D1008235 08\ +n"})->pack(-side => "top"); my $button11 = $mw->Button(-text => "D2008235", -command => sub {print OUTFILE "D2008235 08\ +n"})->pack(-side => "top"); my $button12 = $mw->Button(-text => "D2108235", -command => sub {print OUTFILE "D2108235 08\ +n"})->pack(-side => "top"); my $button13 = $mw->Button(-text => "D2208235", -command => sub {print OUTFILE "D2208235 08\ +n"})->pack(-side => "top"); my $button14 = $mw->Button(-text => "D2608235", -command => sub {print OUTFILE "D2608235 08\ +n"})->pack(-side => "top"); my $button15 = $mw->Button(-text => "D6108 CMPRT09", -command => sub {print OUTFILE "D6108235-1\n +"})->pack(-side => "top"); my $button16 = $mw->Button(-text => "D6108 CMPRT10", -command => sub {print OUTFILE "D6108235-2\n +"})->pack(-side => "top"); my $button17 = $mw->Button(-text => "D6308 CMPRT03", -command => sub {print OUTFILE "D6308235-1\n +"})->pack(-side => "top"); my $button18 = $mw->Button(-text => "D6408235 CMPRT03", -command => sub {print OUTFILE "D6408235-1\n +"})->pack(-side => "top"); my $button19 = $mw->Button(-text => "D6608 CMPRT06", -command => sub {print OUTFILE "D6608235-06\ +n"})->pack(-side => "top"); my $button20 = $mw->Button(-text => "D6608 CMPRT25", -command => sub {print OUTFILE "D6608235-25\ +n"})->pack(-side => "top"); my $button21 = $mw->Button(-text => "D6608 CMPRT26", -command => sub {print OUTFILE "D6608235-26\ +n"})->pack(-side => "top"); my $button22 = $mw->Button(-text => "D6608 CMPRT27", -command => sub {print OUTFILE "D6608235-27\ +n"})->pack(-side => "top"); my $button23 = $mw->Button(-text => "X6108235", -command => sub {print OUTFILE "X6108235 08\ +n"})->pack(-side => "top"); my $button25 = $mw->Button(-text => "D8815235", -command => sub {print OUTFILE "D8815235 15\ +n"})->pack(-side => "top"); my $button26 = $mw->Button(-text => "M1915235", -command => sub {print OUTFILE "M1915235 15\ +n"})->pack(-side => "top"); my $button27 = $mw->Button(-text => "M9015235", -command => sub {print OUTFILE "M9015235 15\ +n"})->pack(-side => "top"); my $button28 = $mw->Button(-text => "M9115235", -command => sub {print OUTFILE "M9115235 15\ +n"})->pack(-side => "top"); my $button29 = $mw->Button(-text => "WR115235", -command => sub {print OUTFILE "WR115235 15\ +nWR415235 15\n"})->pack(-side => "top"); $mw->Button(-text => "Exit", -command => sub{$mw->destroy})->pack(); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Change button color with Tk
by roboticus (Chancellor) on Oct 31, 2017 at 19:29 UTC | |
by PerlCowboy (Novice) on Nov 01, 2017 at 17:26 UTC | |
|
Re: Change button color with Tk
by kcott (Archbishop) on Nov 01, 2017 at 06:30 UTC | |
by PerlCowboy (Novice) on Nov 02, 2017 at 19:23 UTC | |
by Discipulus (Canon) on Nov 02, 2017 at 20:14 UTC |