# Dialog box for editing applicaton intervals sub setAppIntervals { debug("+setAppIntervals"); my $n = shift; # The number of applications # remove 1st value since it's applied before the 1st interval my $n_missing = $#AppInt - $#moreRates; @moreRates = (@moreRates, ("") x $n_missing) if($n_missing > 0); my $appDial = $mainwindow->DialogBox(-title => "Edit application intervals", -buttons => ["Done"]); my $title = "Enter application\nintervals (days)"; # $appDial->Label(-textvariable=> \$title)->pack(-side => "top", # -anchor => "nw", -fill => 'y'); my $lablCol = $appDial->Frame->grid(-row=>0, -column=>0, -sticky=>'nw'); my $intvCol = $appDial->Frame->grid(-row=>0, -column=>1, -sticky=>'nw'); my $rateCol = $appDial->Frame->grid(-row=>0, -column=>2, -sticky=>'nw'); # label the cols, firt col has a blank label to push the col's widgets down $lablCol->Label(-text => "", -width=>6)->pack(-side=>"top",-anchor => "nw"); $intvCol->Label(-text => "interval", -width=>6)->pack(-side => "top", -anchor => "nw"); $rateCol->Label(-text => "rate (kg/ha)", -width=>12)-> pack(-side => "top", -anchor => "nw"); if($n > 1) { for my $i(2..$n) { $lablCol -> Label(-text => "Application $i:",-pady=>2)-> pack(-side => 'top', -anchor => 'nw'); $intvCol->Entry(-width => 6, -bg => 'white', -textvariable => \$AppInt[$i-2])->pack(-side => "top", -padx => 1, -pady=>1, -anchor => "nw"); $rateCol -> Entry(-width => 9, -bg => 'white', -textvariable => \$moreRates[$i-2])->pack(-side=>'top', -padx => 1, -pady => 1, -anchor => 'nw'); } my $result = $appDial->Show; # Execute the dialog box } for(my $i = $#AppInt ; $i>$n-2 ; $i--) { pop @AppInt; # remove extra values from @AppInt pop @moreRates; } debug("-setAppIntervals; rates now set to @moreRates"); }