sub AlignAll{ my ($x1, $y1, $x2, $y2); my $i; my $location; my %pos; foreach $i (0 .. 3) { ($x1, $y1, $x2, $y2) = $sc[$i]->bbox('rect'); $location =int(($x1+$x2)/2); warn("$location"); $pos{$i} = $location; $sc[$i]->xviewMoveto( $location/$initial_width ); } my @pos; foreach my $key (keys %pos ){ push @pos, $pos{$key}; } print "@pos\n"; my $max = &max(@pos); print "$max\n"; #move them all to the most right one, #since those are already at right scroll limit foreach $i (0 .. 3) { print $i," ",join ' ',$sc[$i]->xview(),"\n"; my $diff = $pos{$i} - $max; ############################################### ############################################### #try it with this line # $sc[$i]->xviewScroll($diff, 'units'); ############################################### } } sub max { my $max; for (@_) { $max = $_ if $_ > $max } return $max; } ########################################