Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tk and while loop

Status
Not open for further replies.

kokon

Programmer
Apr 27, 2006
31
PL
Hello, I need to start subroutine before MainLoop() (its a while loop) This is the sub:
--------
sub CheckTime {
$exeTime=18;
$Hour=shift(@_);
$loopStop=0;
while ($loopStop==0) {
sleep(1); # 1 = 1s
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

$ZWIDGETS{'Text1'} -> insert('end',"Waiting......\n");

if ($hour==$exeTime) { $loopStop=1; $ZWIDGETS{'Text1'} -> insert('end',"Starting.....\n");}
}
return $hour;
}
----------------------------------------
And when I put it in this way, first program do the while loop and than start window:
-----------------------------------------
&CheckTime($HourGet);
MainLoop();
----------------------------------------
I need the subroutine works all the time and update Tk Text box...

I have try use the threads but Tk and threads works really bad.

Thx for help..
 
Is there sth in perl like onForm_Load????
 
where to put $mw->update; ???
 
In your while loop, silly.

Code:
while (1) {
   sleep 1;
   $mw->update;
   # do stuff
}

And to answer your next question, $mw would be your MainWindow object, e.g.

Code:
my $mw = MainWindow->new;

So change it if your MainWindow is in a different variable name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top