同时创建一个部件和滚动条
一个滚动条是 显示2个箭头,在滚动条的2侧,中间部分是滑动块
它提供了相关窗口的信息,来显示一些排序的文档。
滑动块的位置和尺寸表明文档可见的部分
#!/usr/bin/perl -w
use Tk;
my $mw = new MainWindow;
$f = $mw->Frame( )->pack(-side => 'top', -expand => 1, -fill => 'both');
$xscroll = $f->Scrollbar(-orient => 'horizontal');
$yscroll = $f->Scrollbar( );
$lb = $f->Listbox(-width => 50, -height => 12, -yscrollcommand => ['set', $yscroll], -xscrollcommand => ['set', $xscroll]);
$xscroll->configure(-command => ['xview', $lb]);
$yscroll->configure(-command => ['yview', $lb]);
$xscroll->pack(-side => 'bottom', -fill => 'x');
$yscroll->pack(-side => 'right', -fill => 'y');
$lb->pack(-side => 'bottom', -fill => 'both', -expand => 1); open (FH, "H:/运维系统开发/Tk/1/1.txt") || die "Could not open chapter1"; while (<FH>) { $lb->insert('end', $_); } close(FH);
MainLoop