Problem with scrollbar cooperating with text widget
Allen Liu <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Hi All,
I am having trouble using scrollbar with my text widget. This is how I
initialize my scrollbar and text widgets.
my $scrollbar = $mw->Scrollbar();
my $text = $mw->Text(-background => 'white',
-yscrollcommand => [$scrollbar => 'set'],
)->pack(-side => 'left', -fill => 'both');
$scrollbar->configure(-command => ['yview' => $text]);
$scrollbar->pack(-side => 'left', -fill => 'y');
It is basically by the book, literally (Mastering Perl/Tk by O'Reilly). The
scroll bar works fine when I start editing my own text in the text field.
However, when I run a subroutine that adds a long list of checkboxes, the
scrollbar ceases to function. The list of checkboxes exceeds the height of
the text window so I am not able to view past the bottom of the text window.
It seems that the scrollbar does not even know that I have added new
content to the window so it is not responding accordingly. This is the
code for my subroutine (the checkboxes gets added at the end of the code):
sub parse_blast {
my @cb;
my $count = -1;
my $background;
my $infile = shift;
my $in = new Bio::SearchIO(-format => 'blast',
-file => "$infile");
while( my $result = $in->next_result ) {
while( my $hit = $result->next_hit ) {
while( my $hsp = $hit->next_hsp ) {
$count++;
if(($count%2) == 0) {
$background = 'grey92';
}
else { $background = 'white'; }
my $name;
my $length;
my $accession;
my $description;
my $score;
my $significance;
my $percent_identity;
$name = $hit->name;
$length = $hit->length;
$accession = $hit->accession;
if ($name =~ /\|$/) {
$name =~ /(\w+\|.+)\|/;
$name = $1;
#print "===>>> $name\n";
}
$description = $hit->description;
$score = $hit->raw_score;
$significance = $hit->significance;
$percent_identity = $hsp->percent_identity;
if($percent_identity =~ /\d+\.\d+/) {
$percent_identity =~ /(\d+\.\d{2})/;
$percent_identity = $1;
}
#print "Hit= ", $hit->name,
# ",Length=", $hsp->length('total'),
# ",Percent_id=", $hsp->percent_identity, "\n";
$cb[$count] = $text->Checkbutton(-text => "\n$name|$accession
$description\nLength = $length\tPercent Identity = $percent_identity\tScore
= $score\tExpect = $significance\n",
-variable => \$accession{$name},
-activebackground => 'gray70',
-anchor => 'w',
-wraplength => 1000,
#-takefocus => 1,
-justify => 'left',
-background => $background,
-relief => 'flat',
#-font => 'arial'
)->pack(-fill => 'x', -expand => 1, -side => 'top', -anchor =>
'w');
}
}
}
}
Am I supposed to configure scrollbar after I add each checkbox so that it
knows that these checkboxes exist?
Any advice would be greatly appreciated.
Allen Liu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sherman Fairchild Bldg.
Room D148
Stanford University
Stanford, CA 94305-5126 USA
Tel. 650-723-6622
Email [email protected]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]