Mark text in a Scrolled Text Widget : Text « GUI « Perl

Home
Perl
1.Array
2.CGI
3.Class
4.Data Type
5.Database
6.File
7.GUI
8.Hash
9.Language Basics
10.Network
11.Regular Expression
12.Report
13.Statement
14.String
15.Subroutine
16.System Functions
17.Win32
18.XML
Perl » GUI » Text 
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;

   
  
Related examples in the same category
1.Bind mouse double click action to a Text control
2.Call Text insert function to add text to a Text control
3.Insert text to a Text control (TextField)
4.Set width and height of a Text
5.Use the Scrolled to control the scroll of a Text Entry
6.Change text in a Text (TextField) in radio button and checkbox button action
7.Configure a Text Widget
8.Create a scrolled Text widget
9.Entry(text field): Set highlightthickness
10.Entry(text field): set font
11.Fill the Entry (text field): textvariable
12.Get text input in a single line Text Box
13.Insert bold text to a Text widget
14.Insert text string to a Text Widget
15.Auto-scroll entry (text field)
16.Single-Line Text Entry
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.