|
PerlTK loose control in loop
I have been trying to make a timer in perl for my TK gui to update information as it changes. I did try some code with Sig Alarm but it doesnt work when you are idle so I came up with this.
#! usr/bin/perl
use Tk;
Lots of fun GUI stuff here
for ( ; ; ) {
code that needs to work every 3 seconds
for ($i=0; $i<30000000; $i++) { #takes about 3 seconds
}
}
MainLoop; #end of TK loop
This does do the comands every 3 seconds but control of the gui is completly gone and it just keeps processing the info every 3 seconds but doesnt display becuase GUI has lost control..
Note: Added the timer in a sub routine thats called by a button becuase if I dont do that the GUI will not even load up it will process the loop forever since it is infinate and never make a gui!!!
I am new to perl and do not know whats wrong, Does anyone got any ideas or suggestions to fix this problem or a better way to do it????????
Thanx in advance
Last edited by Atrocity; 05-10-2005 at 11:09 AM.
|