Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just wanted to say THANKS for the forum. The knowledge I gain from your site is invaluable..."

Geography

Where in the world do Tek-Tips members come from?

TK - How to update Window automatically

TSch (TechnicalUser)
6 Aug 12 9:54
Hi everyone,

I'm trying to write a little "graphical" print queue monitor that's supposed to count the number of files in a certain directory and draw a line according to the number of files.

So far I managed to write a little window that draws the line as intended, but only once ...

How do I get the window to update automatically every few seconds ?

CODE

#!/usr/bin/perl -w

use strict;
use Tk;

my $window= MainWindow->new;
my $c1 = $window->Canvas(-background => 'saddlebrown', -width => '350', -height => '150')->pack;

$c1->createText(175, 10, -fill => 'orange', -text => 'Print Queue Monitor');
$c1->createLine(0, 20, 351, 20, -fill => 'orange');

my $jobs01=`ls -all | wc -l | awk \'{print \$1}\'`;
chomp ($jobs01);
$jobs01 +=88;

$c1->createLine(88, 65, $jobs01, 65, -width => '10', -fill => 'green');
$c1->createText(45, 65, -fill => 'orange', -text => 'Spooler Queue');
MainLoop; 

Any ideas ?

Best Regards,
Thomas
PaulTEG (TechnicalUser)
23 Aug 12 17:54
Put the line which draws the line inside a while loop, and sleep ?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments winky smile

kordaff (Programmer)
5 Sep 12 20:41
Look at perldoc Tk::after. You can set up a callback to draw the line every few seconds in a subroutine.

CODE

my $id = $c1->repeat( 2500, \&draw_line );
MainLoop;

sub draw_line
  {
  # put the line drawing code here
  } 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close