2011-07-26 2 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

확인해 보았습니다. 문제는 세로 스크롤 막대가 목록 상자의 높이에 맞춰진 것입니다. 기본 설정에는 기하 설정에서 설정 한 높이 내에 10 개가 있습니다. 실제 높이를 설정 한 모든 목록 상자를 채운 후 선을 추가하면 스크롤 막대가 작동하기 시작합니다.