#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; $mw->fontCreate('big', -family=>'courier', -weight=>'bold', -size=>int(-18*18/14)); my $tx = $mw->Text( -height => 4, #initialy set it small -width => 25, )->pack(); foreach (1 .. 20 ) { $tx->insert( 'end', "line$_\n" ); } $tx->insert('end', "Blah " x 10); my $end = $tx->index('insert'); #get last line $tx->configure(-height=>$end); my $button = $mw->Button(-text=>'Reconfigure', -command=>sub{ $tx->configure(-font => 'big'); $tx->update; $tx->configure(-height => $end); }, )->pack(); MainLoop;