Posted to tcl by patthoyts at Mon Sep 04 13:05:26 GMT 2006view pretty
# Sample perl/tk to load self into a scrolled text widget # use strict; use Tk; my $cw = Tk::MainWindow->new(-title => 'Perl/Tk Sample'); my $txt = $cw->Scrolled("Text", -scrollbars => 'se') ->pack(-expand => 'both', -pady => '2'); $txt->tagConfigure('comment', -foreground=>'red'); open(FH, $::0) || die "failed $!"; while (<FH>) { my $tag = ''; $tag = 'comment' if (/^#/); $txt->insert('end', $_, $tag); $tag = ''; } close FH; Tk::MainLoop;