Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Refresh data ina entry widget

by zentara (Archbishop)
on May 29, 2008 at 11:38 UTC ( #688997=note: print w/replies, xml ) Need Help??


in reply to Refresh data ina entry widget

Whenever you want a refresh on a time period in Tk, you probably want a timer.
$mw->repeat(1000, \&status_bank); sub status_bank{ ......... do your extraction from file $mw->update; }
If you have alot of banks and entries, put them all in a hash, and loop thru them, like this pseudocode:
my %box_banamex; $box_banamex{$bank}{'entry'} = $upperframe->Entry(......... -textvariable => \$box_banamex{$bank}{'status'}, foreach my $bank (keys %box_banamex){ #read each value from file $box_banamex{$bank}{'status'} = whatever from file parsing; $box_banamex{$bank}{'entry'}->update; }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: Refresh data ina entry widget
by padawan_linuxero (Scribe) on May 29, 2008 at 15:24 UTC
    Hi
    I am trying really trying but can you please elaborate more on the pseudocode because i dont get it, please?
      Pseudocode means "this is a non-functional shorthand view" of the steps you would need to take to write working code. I don't particularly like being asked to write code for someone who is getting paid for it. So here is a general purpose example, if you can't figure out the rest, you should read some books.
      #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); my %data; foreach my $bank qw(aa bb cc dd){ $data{$bank}{'frame'} = $mw->Frame->pack(); $data{$bank}{'bankname'} = $bank; $data{$bank}{'status'} = 'offline'; $data{$bank}{'label'} = $data{$bank}{'frame'}->Label( -textvariable => \$data{$bank}{'bankname'})->pack(-side=>'left') +; $data{$bank}{'entry'} = $data{$bank}{'frame'}->Entry( -textvariable => \$data{$bank}{'status'}, -bg => 'white', )->pack(-side=>'right'); } $mw->repeat(2000, sub{ foreach my $bank (keys %data){ my $rand = rand 10; if ($rand > 5){ $data{$bank}{'status'} = 'online'; $data{$bank}{'entry'}->configure(-fg => 'red'); }else{ $data{$bank}{'status'} = 'offline'; $data{$bank}{'entry'}->configure(-fg => 'black'); } } }); MainLoop;

      I'm not really a human, but I play one on earth CandyGram for Mongo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://688997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2019-07-18 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?