Here is a complete simple example.# while (<FH>) { $right_frame->insert("end", $_); } # should be something like this while (<FH>) { $right_frame->insert("end", $_, $tag); }
#!/usr/bin/perl use warnings; use strict; use Tk; open (FH,"<$0") or warn "$!\n"; my @lines = <FH>; close FH; my $mw = MainWindow->new(-title=>'Colored Text'); $mw->geometry(($mw->screenwidth-10) . 'x' . ($mw->screenheight-10) . '+0+20'); $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size => 25 ); my $text = $mw->Scrolled("Text", -scrollbars => 'osw', -background => 'white', -font =>'big', -wrap => 'none', )->pack; $text->tagConfigure('greyline', -background => 'grey95'); my $toggle = -1; for (@lines) { my $greyline; if( $toggle == 1 ){ my $greyline = '' } else { $greyline = 'greyline' } $text->insert('end',"$_",$greyline); $toggle *= -1; } MainLoop;
In reply to Re: Perl tk how to change text widget font colour on multiple lines
by zentara
in thread Perl tk how to change text widget font colour on multiple lines
by john.tm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |