use Tk; use strict; use warnings; sub something { my $box = shift; $box->delete("1.0", "end"); $box->insert("end", $_) for (1 .. 100); } my $mw = MainWindow->new(title=>"Scrollbar Demo"); my $box = $mw->Scrolled(qw/Text -width 100 -height 15 -scrollbars se/)->pack; $mw->Button(text=>"click", command=>[\&something, $box])->pack; MainLoop;