我有一个滚动窗格,然后填充一系列长列表框来制作图表。底部的滚动条工作正常,但右侧的滚动条表示查看区域外没有任何内容,但是当我调整窗口大小时,我看到许多行被隐藏。我已经尝试在各种订单中打包框架和列表框(打包列表框然后填充它们,填充列表框以便它们已满,然后打包它们等)但是不管我做什么,右侧的滚动条都没有似乎无法理解列表框比窗格高。
实际程序稍微复杂一些,但这是一个简化的例子,它通过限制几何来显示行为。在我的实际情况中,我永远不知道图形的宽度或高度,但如果我没有为几何图形指定某些东西,则窗口非常小。
use strict;
use Tk;
require Tk::Pane;
my $mw = MainWindow->new;
my $graph_button = $mw->Button(-text => 'Make Graph',-command => sub {&make_graph} )->pack();
MainLoop;
exit;
sub make_graph {
my $summary_tl = $mw->Toplevel( -title => "My graph" );
$summary_tl->geometry("500x200");
my $summary_frame = $summary_tl->Scrolled ( "Pane",
-scrollbars => "se",
-sticky => 'nesw',
)->pack(-fill=>'both',-expand=>1);
# First column holds the names
my $name_frame = $summary_frame->Frame()->pack(-side=>'left',-fill=>'both',-expand=>1);
my $name_lb = $name_frame->Listbox (-width=>0,-relief=>'flat',-borderwidth=>0)->pack(-side=>'top',-fill=>'both',-expand=>1);
$name_lb->insert('end',"Names");
# Second column shows the overall status
my $overall_frame = $summary_frame->Frame()->pack(-side=>'left',-fill=>'both',-expand=>1,);
my $overall_lb = $overall_frame->Listbox (-width=>0,-relief=>'flat',-borderwidth=>0)->pack(-side=>'top',-fill=>'both',-expand=>1);
$overall_lb->insert('end',"Overall Status");
# The next remaining columns are one per check of the current checklist, with the check number being the header.
my %stat_frame = ();
my %stat_lb = ();
foreach my $check_num (qw /1 2 3 4 5 6 7 8 9 10/) {
$stat_frame{$check_num} = $summary_frame->Frame()->pack(-side=>'left',-fill=>'both',-expand=>1);
$stat_lb{$check_num} = $stat_frame{$check_num}->Listbox(-width=>0,-relief=>'flat',-borderwidth=>0,) -> pack(-side=>'top',-fill=>'both',-expand=>1);
$stat_lb{$check_num}->insert('end',"Check $check_num");
}
# Now go through and add each row
foreach my $name (qw /a b c d e f g h i j k l m n o p q r s t u v w x y z/) {
$name_lb->insert('end',$name);
$overall_lb->insert('end',"pass");
foreach my $check_num (qw /1 2 3 4 5 6 7 8 9 10/) {
$stat_lb{$check_num} -> insert('end',"Status");
}
}
} # end make_graph subroutine
答案 0 :(得分:1)
好的,我想出来了。问题是垂直滚动条被键入列表框的高度。默认值为10,这完全在我在几何设置中设置的高度范围内。当我填充所有设置真实高度的列表框后添加一行时,滚动条开始工作。