in reply to Re^4: Perl tk - open file and print content
in thread Perl tk - open file and print content
You can't print in the $mw directly, but you can print to a Scrolled Text Widget in the $mw.
#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Perl tk - open file and print content
by Giorgio C (Novice) on Jan 20, 2012 at 10:58 UTC | |
by zentara (Cardinal) on Jan 21, 2012 at 11:19 UTC | |
by Giorgio C (Novice) on Jan 23, 2012 at 12:29 UTC | |
by Anonymous Monk on Jan 23, 2012 at 12:48 UTC | |
by Giorgio C (Novice) on Jan 23, 2012 at 14:44 UTC |