Anthony asks:
> I want to be able to display the status of the script
> as it runs.
> I thought I could use TK but I dont want the program
> to be interactive (just to display messages) and TK
> waits for an exit statement b/4 running anything after
> MainLoop. What I reall need is a display object I can
> create and change at various points in the script.

Eithan adds:
> I work in interop (Unix and Win32) and I need to display a
> non-interactive message (such as 'waiting' or 'loading'
> or 'in >progress') while I perform some time-consuming
> task (query a remote db, loading a 'heavy' application
> etc.). [...]


Why all the drama of another thread?

vvvvv SAMPLE CODE vvvvv
#!perl -w

++$|;

use strict;
use warnings;

use Tk;

my $StatWin = MainWindow->new();
$StatWin->title( 'Please wait.');
$StatWin->bind( '<Escape>', sub{ destroy $StatWin; $StatWin
= undef; } );

my $body_text = $StatWin->Text( -width=>30, -height=>20,
-wrap=>'word')
      ->pack( -side=>'top');

$StatWin->Button(
         -text => 'close',
         -command => sub{ destroy $StatWin; $StatWin=undef;
}
      )->pack( -side => 'bottom');

$body_text->insert( 'end', "Please be patient.\n");
$StatWin->focusForce;
$StatWin->update;

# Do your stuff.  Call "update" to repaint msg box.
     for (my $i=0;  $i<10;  ++$i)
     {
        print "Working $i...\n";
        sleep( 1);

        if ($StatWin)
        {
#          $body_text->delete( '0.0', 'end');
           $body_text->insert( 'end', "Working $i...\n");
           $StatWin->update;
        }
     }

$StatWin->destroy
   if $StatWin;

print "Window should be gone now.\n";
sleep( 3);
^^^ END SAMPLE CODE ^^^

-- 
pDale Campbell
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to