#!/usr/bin/perl use Tk; use strict; my @parts = ("11111", "22222", "33333", "44444", "55555"); my @labels; my @entries; my @add_boxes; my $main = new MainWindow; my $i = 0; my $k = 0; while ($parts[$i]) { my $j = $i; $labels[$j] = $main->Label( -text => $parts[$j] ) ->grid( -column => 0, -row => $k ); $entries[$j] = $main->Entry( -background => 'white', -width => 8 ) ->grid( -column => 1, -row => $k ); $entries[$j]->insert('end', '0'); $add_boxes[$j] = $main->Entry( -background => 'white', -width => 8 ) ->grid( -column => 2, -row => $k ); $add_boxes[$j]->bind( "", sub { my $currentqty = $entries[$j]->get; my $addqty = $add_boxes[$j]->get; $entries[$j]->delete('0.0', 'end'); $add_boxes[$j]->delete('0.0', 'end'); $entries[$j]->insert( 'end', $currentqty + $addqty ); $main->update; } ); $i++; $k++; } MainLoop;