Mega Code Archive

 
Categories / Perl / GUI
 

Mark text in a Scrolled Text Widget

#!/usr/local/bin/perl -w use Tk; use strict; my $mw = MainWindow->new; my $t = $mw->Scrolled('Text')->pack(-fill => 'both', -expand => 1); $t->insert('end', "test"); $t->markSet('one', '1.3'); $mw->Button(-text =>'left',              -command => sub {                 $t->markGravity('one', 'left');                 $t->insert('one', '***');                 }            )->pack(-side => 'left'); $mw->Button(-text =>'right',              -command => sub {                $t->markGravity('one', 'right');                $t->insert('one', '***');              }            )->pack(-side => 'left'); $mw->Button(-text => "Report",              -command => sub {                my @m = $t->markNames();                foreach (@m) {                   print "MARK: $_ at ", $t->index($_), "\n";               }             }            )->pack(-side => 'left'); MainLoop;