Syntactic Confectionery Delight | |
PerlMonks |
Re: Tk version Geek clockby {NULE} (Hermit) |
on Jan 02, 2003 at 00:02 UTC ( [id://223649]=note: print w/replies, xml ) | Need Help?? |
Hi there,
pg is completely correct - look up Tk::after - using after or repeat is the way to do this. But on a side note, if your program is not going to be interactive you don't *need* to use MainLoop. (I don't know why I'm mentioning this - I have a bad habit of bringing up the Wrong Way To Do It, just because I think it's interesting. I can feel the -- already.) Instead of calling MainLoop you can write you own loop at the end that looks something like this: But don't do that! The only good excuse that I can think of for doing something like this is if you want to popup a Tk status bar as your MainWindow while a script is doing something in the background (like parsing a really big file). In that case you don't need the interaction and the user is just sitting there and waiting for your script to stop running anyway. By the way - I applaud your use of strict (and presumably warnings), but even with your my scoping your @blocks array is still being treated as a global. My preference is to pass a reference to you array around instead of just implying that you mean to use it globally. What I like to do is create a $w hash and a $s hash and fill them with widgets and state information, then pass them to functions or Tk callbacks via reference. Of course, that is just a poor-persons form of OO, and works fine for simple scripts. This is what I mean: Anyway - just some food for thought. TMTOWTDI. {NULE} -- http://www.nule.org
In Section
Seekers of Perl Wisdom
|
|