use warnings; use strict; use Tk; 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, @_) } ); MainLoop; sub getText { my ($t, @args) = @_; my $text = $t->get('0.0', 'end'); print "Got: $text\n"; return if(!$text); return 1; }