in reply to Problem with duplicate Entry in One frame

Hi thanks, but my problem continues you see this is what is happenning on the screen :
STATUS : BANK1 ACTIVE BANK2 ACTIVE BANK3 ACTIVE STATUS : BANK1 ACTIVE. +...
What you really need to do then is to update the widgets that you've already created, and in order to do that you'll need to keep track of the which widgets are associated with which banks.
my $upframe = ...; my %entry_widget; # stores the entry widget for a bank sub update_bank_status { my ($upframe, $bank, $status) = @_; my $entry = $entry_widget{$bank}; unless ($entry) { $entry_widget{$bank} = ...create a new label and entry widget... } $entry->configure(-text => $status); $entry->configure(-foreground => $status eq "ACTIVO" ? "blue" : "red"); } sub update_statuses { ...open file... while (<FILE>) { my ($bank, $status) = ...parse info...; update_bank_status($upframe, $bank, $status); } close(FILE); }
And then you call update_statuses() every 10 seconds.

Replies are listed 'Best First'.
Re^2: Problem with duplicate Entry in One frame
by padawan_linuxero (Scribe) on May 20, 2008 at 20:14 UTC
    Hi I follow your code
    but perhpas I am doing something wrong, can you tell me what is wrong?
    this is the code :
    sub update_bank_status { my ($upframe, $bank, $status) = @_; my $entry = $entry_widget{$bank}; unless ($entry) { $entry_widget{$bank} = $upframe -> Label ( -textvariable => \$bank )-> pack ( -side => 'left', -expand => 1 ); $upframe -> Entry ( - width => 20 )-> pack (-side => 'left', -expand => 1); } $entry -> configure (-text => $status); $entry -> configure (-foreground => $status eq "ACTIVO" ? "blue" : + "red" ); } sub update_statuses { open(FILE, "santa1.txt") || die("Could not open file!"); my @stat1=<FILE>; #close(FILE); while (<FILE>) { my ($bank, $status) = split(/\|/,@stat1); print $bank; print $status; update_bank_status ($upframe, $bank, $status); } close (FILE); }
    inside the mainloop I put this :
    $mw->repeat(5000, \&update_statuses);
    Thank you!!! I really apreciate the effort