GriffinP has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am looking for code examples (or snippets) of Perl/TK Hlists or tables that perform periodic auto-refreshing of table rows (e.g., perhaps using the $widget->repeat/entryconfigure functions?)
I'm interested in displaying a table that auto-updates every N seconds. For example, here is a trivial TK/HList that produces a STATIC display of the current set of running processes. I'd like to explore versions of this code where the Hlist rows autoupdate every N seconds (e.g., row attributes update, rows disappear, rows are added). One could do this by cycling through MainWindow->new / MainWindow->destroy / MainWindow->new, but that's very clunky and causes table flashing.
use Tk; use Tk::HList; use Win32::ToolHelp; my @plist; my $col = 0; &getprocHash(); my $mw = MainWindow->new; $mw->resizable(1,1); $mw->title("static process list"); $mw->geometry("400x250+80+100"); my $hlist = $mw->HList(-columns=>5, -header=>1, -background=>"white", -command=>, -browsecmd=>,-selectmode=> 'single')->pack(-fill=>'both', -expand=>'yes'); foreach my $label (qw/PID Threads AID Priority Name/) { $hlist->header('create',$col++,-itemtype=>'text',-text=>$label) ; } foreach my $p (@plist) { my $e = $hlist->addchild(""); $col = 0; foreach $i (1,4,5,6,8) { $hlist->itemCreate($e,$col++, -itemtype=>'text',-text=>"$$p[$i]"); } } MainLoop; exit (0); sub getprocHash { @plist = Win32::ToolHelp::GetProcesses(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Auto-refreshing Perl TK HLists/Tables
by zentara (Cardinal) on Mar 25, 2011 at 14:14 UTC | |
|
Re: Auto-refreshing Perl TK HLists/Tables
by stefbv (Priest) on Mar 25, 2011 at 07:07 UTC |