2011-07-26 13 views
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 

答えて

1

OK、これを理解しました。問題は、垂直スクロールバーがリストボックスの高さにキーインされていることでした。既定値には、ジオメトリ設定で設定した高さ内にあった10があります。本当の高さを設定するすべてのリストボックスに値を設定した後に行を追加すると、スクロールバーが機能し始めました。

関連する問題