programming-examples/perl/GUI/Mark text in a Scrolled Text Widget.pl

34 lines
906 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/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;