use Tk; use strict; require Tk::ROText; my $rotext_box; my $frame; my $count=0; my $mw = MainWindow->new; $mw->title("Scrollbar_View"); $mw->geometry("500x300"); $mw->resizable(0,0); my $frame1 = $mw->Frame()->pack(-side => 'top'); my $send_cmd_btn = $frame1->Button(-text => 'Send_Cmd', -state=>'normal', -command =>\&show) ->pack(-side=>'left', -padx=>5); $frame = $mw->Frame(-relief => 'groove', -background=>'white') ->pack(-side => 'top', -fill=>'x', -fill=>'y'); my $xscroll = $frame->Scrollbar(-orient => 'horizontal'); my $yscroll = $frame->Scrollbar(); $rotext_box = $frame->ROText(-background =>'white', -height => 25, -width => 120, -xscrollcommand => ['set' , $xscroll], -yscrollcommand => ['set', $yscroll] ); $xscroll->configure(-command => ['xview', $rotext_box]); $yscroll->configure(-command => ['yview', $rotext_box]); $xscroll->pack(-side => 'bottom', -fill => 'x'); $yscroll->pack(-side => 'right', -fill => 'y'); $rotext_box->pack(-side => 'bottom', -fill => 'y'); MainLoop(); sub show { Tk::DoOneEvent(0); my $text_to_Insert = "This is a large text that is displayed in the ROText for $count time\n\n\n"; $rotext_box -> insert('end', $text_to_Insert); $rotext_box->update(); $count++; }