CorpusDawg has asked for the wisdom of the Perl Monks concerning the following question:
#!\Perl\bin -w use Tk; $statfile = "c:\\data\\test.txt"; print "BEFORE WHILE\n"; open (FILE, $statfile) || die "Couldn't open file: $!"; my @statarray = <FILE>; foreach (@statarray){chomp;} #####Create Main GUI WINDOW###### my $main = MainWindow->new(); $main->title("FLOWINFO - Port Freeport Real-Time Navigation System"); #####BEGIN MENUBAR CREATION###### my $menu_bar = $main->Frame(-relief => 'groove', -borderwidth => 3)->p +ack(-side=>'top', -fill => 'x'); my $file_mb = $menu_bar->Menubutton(-text => 'File')->pack(-side=>'lef +t'); $file_mb->command(-label => 'Exit', -command => sub{$main->destroy}); my $help_mb = $menu_bar->Menubutton(-text => 'Help')->pack(-side => 'r +ight'); $help_mb->command(-label=>'About', -command =>\&about); $help_mb->command(-label=>'Help', -command =>\&help); ####BEGIN BUILDING GUI BODY######## my $top = $main -> Frame -> pack(-side=>'top', -fill =>'x'); my $left1 = $top -> Frame -> pack(-side =>'left',-pady =>9, -padx => 8 +); ##############MET############################## my $metlabel = $left1 -> Label(-text => ' METEORLOGICAL SENSORS')->pac +k(); $metsensor= $left1->Label(-text =>' Wind Speed ')->pack(); $metsensor= $left1->Label(-text =>' Wind Direction ')->pack(); $metsensor= $left1->Label(-text =>' Air Temperature ')->pack(); $metsensor= $left1->Label(-text =>' Barometric Pressure ')->pack(); $metsensor= $left1->Label(-text =>' Average Gust ')->pack(); my $left2 = $top -> Frame ->pack(-side=>'left',-pady => 2, -padx => 15 +); my $metstatlabel = $left2->Label(-text => 'METEORLOGICAL MEASUREMENTS' +)->pack(); #############ADCP############################## my $right1 = $top -> Frame ->pack(-side=>'right', -pady => 2, -padx=>1 +5); my $adcpstatlabel = $right1->Label(-text => 'ADCP MEASUREMENTS')->pack +(); my $right2 = $top ->Frame ->pack(-side=>'right'); my $adcplabel = $right2->Label(-text => 'ADCP SENSORS')->pack(); $adcpsensor = $right2->Label(-text => 'Drift')->pack(); $adcpsensor = $right2->Label(-text => 'Set')->pack(); $adcpsensor = $right2->Label(-text => 'Water Depth')->pack(); $adcpsensor = $right2->Label(-text => 'Water Temperature')->pack(); close FILE; print "closed File\n"; $main->bind("<Alt-F4>" => sub{exit}); print "Updating Array\n"; $main->repeat( 20000 => \&array_update); MainLoop(); sub array_update { open (FILE, $statfile) || die "Couldn't open file: $!"; my @statarray = <FILE>; close FILE; foreach (@statarray){chomp;} $metstat1->destroy() if Tk::Exists($metstat1); $metstat2->destroy() if Tk::Exists($metstat1); $metstat3->destroy() if Tk::Exists($metstat1); $metstat4->destroy() if Tk::Exists($metstat1); $metstat5->destroy() if Tk::Exists($metstat1); $adcpstat1->destroy() if Tk::Exists(adcpstat1); $adcpstat2->destroy() if Tk::Exists(adcpstat1); $adcpstat3->destroy() if Tk::Exists(adcpstat1); $adcpstat4->destroy() if Tk::Exists(adcpstat1); $metstat1 = $left2->Entry(-width => 5, -textvariable => \$statarray[0] +, -relief => 'sunken')->pack(); $metstat2 = $left2->Entry(-width => 5, -textvariable => \$statarray[1] +, -relief => 'sunken')->pack(); $metstat3 = $left2->Entry(-width => 5, -textvariable => \$statarray[2] +, -relief => 'sunken')->pack(); $metstat4 = $left2->Entry(-width => 5, -textvariable => \$statarray[3] +, -relief => 'sunken')->pack(); $metstat5 = $left2->Entry(-width => 5, -textvariable => \$statarray[4] +, -relief => 'sunken')->pack(); $adcpstat1 = $right1->Entry(-width => 5, -textvariable => \$statarray[ +5], -relief =>'sunken')->pack(); $adcpstat2 = $right1->Entry(-width => 5, -textvariable => \$statarray[ +6], -relief =>'sunken')->pack(); $adcpstat3 = $right1->Entry(-width => 5, -textvariable => \$statarray[ +7], -relief =>'sunken')->pack(); $adcpstat4 = $right1->Entry(-width => 5, -textvariable => \$statarray[ +8], -relief =>'sunken')->pack(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem refreshing TK window after file update
by atcroft (Abbot) on Apr 30, 2004 at 15:47 UTC | |
|
Re: Problem refreshing TK window after file update
by Popcorn Dave (Abbot) on Apr 30, 2004 at 16:06 UTC | |
|
Re: Problem refreshing TK window after file update
by zentara (Cardinal) on May 01, 2004 at 13:42 UTC |