I'm not sure what you want to see, so below is the code for the whole subroutine I'm writing
The whole reason I have this subroutine is for user to select some items in the @newSeqUnique array and return the selected array to the calling function
Currently the code is stuck at the MainLoop; statement
sub getSelectedSeq {
my $newSeqUniqueRef = shift; my $grp = shift;
my @newSeqUnique = @$newSeqUniqueRef;
my @newSeqUniqueSorted = sort{$a->{ID} cmp $b->{ID} ||
$a->{folder} cmp $b->{folder}} @newSeqUnique;
my @displayedArr; my $displayedStr;
my @selectedArr;
foreach (@newSeqUniqueSorted) {
$displayedStr = $_->{ID}." - ".$_->{folder};
push (@displayedArr, $displayedStr);
}
select STDOUT;
foreach (@displayedArr) {
print "$_\n";
}
# my $mw = MainWindow->new(-title=>"Select sequences");
my $mw = new MainWindow;
$mw->Label(-text => "Below is a list of sequences not found in exi
+sting group $grp table")->pack();
$mw->Label(-text => "Please select sequences to be added to new ta
+ble")->pack();
my $lb = $mw->Scrolled("Listbox",
-scrollbars => "osoe",
-height =>10,
-width => 30,
-selectmode => "extended");
my $real_lb = $lb->Subwidget('scrolled');
$real_lb->configure(-borderwidth=>2);
$lb->insert("end", @displayedArr);
$lb->pack(-fill=>"both");
$mw->Button(-text => "Select",
-command => sub{@selectedArr=$lb->curselection;$m
+w->destroy();})->pack();
$lb->selectionSet('end');
$lb->see('end');
MainLoop();
foreach (@selectedArr) {
print "$_\n";
}
my @arr; my @temp; my ($index, $ID, $folder, $obj);
if ((@selectedArr)&&(defined $selectedArr[0])) {
foreach (@selectedArr) {
push (@arr, $newSeqUniqueSorted[$_]);
}
}else {
@arr = ();
}
return \@arr;
}
|