#!/usr/local/bin/perl #an index is passed to the insert method to insert text into the text widget. #the index is passed along with the text to be inserted. #There are two general ways to specify an index for Tk: #01- use the end token. #02- specify the row.position combination. #the row is 1-based and the position is 0-based. use strict; use warnings; use Tk; my ($main, $text); $main=MainWindow->new(); $main->Button( -text=>'Type', -relief=>'raised', -command=>\&display)->pack; $main->Button( -text=>'delete', -relief=>'ridge', -command=>\&deleting)->pack; $main->Button( -text=>'exit', -relief=>'groove', -command=>[$main=>'destroy'] )->pack; $main->Button( -text=>'Position', -relief=>'raised', -command=>\&position )->pack; $text=$main->Text(-width=>40, -height=>8)->pack; sub display{ $text->insert('2.0', "Greetings\n"); #insert at the secondRow.FirstPosition, #This only works after deleting text from the text widget } sub deleting{ $text->delete('1.0','2.9'); } sub position{ $text->get('2.0','1.9'); } MainLoop;