#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Text; my $MW = MainWindow->new( -title => "Tk::Text test", -width => 200, -height => 200 ); my $text = $MW->Text( -height => 10, -width => 40, -wrap => 'word' ); $text->pack( -side => 'top', -fill => 'both' ); $text->bind( '<>' => sub { getText( $text, @_ ); } ); $MW->Button(-text=>'Clear Modified Flag', -command => sub{ $text->editModified(0) } )->pack(); MainLoop; sub getText { my ( $t, @args ) = @_; my $text = $t->get( '0.0', 'end' ); print "Got: $text\n"; return if ( !$text ); return 1; }