0

我有一个滚动窗格,然后填充一系列长列表框以制作图表。底部的滚动条完美运行,但右侧的滚动条表明在查看区域之外没有任何内容,但是当我调整窗口大小时,我看到很多行被隐藏了。我已经尝试以各种顺序打包框架和列表框(打包列表框然后填充它们,填充列表框以使其充满然后打包它们等),但无论我做什么,右侧的滚动条都不会似乎不理解列表框比窗格高。

实际的程序稍微复杂一些,但这里有一个简化的示例,通过限制几何来显示行为。在我的真实情况下,我永远不知道图形的宽度或高度,但如果我没有为几何图形指定一些东西,窗口就会非常小。

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
4

1 回答 1

1

好的,我想通了。问题是垂直滚动条被键入到列表框的高度。默认值为 10,这正好在我在几何设置中设置的高度之内。当我在填充所有设置真实高度的列表框后添加一行时,滚动条开始工作。

于 2011-07-27T19:06:29.383 回答