DreamT has asked for the wisdom of the Perl Monks concerning the following question:

Hi!
I've just been starting out with Tkx, and have one question. Now I do the following:
... &my_routine(); Tkx::MainLoop(); exit; ...
The purpose of "my_routine" is to update a textbox every n seconds. But, the above code runs the routine only once (of course). I want to find a way to run it DURING the Tkx::MainLoop. How can I do that?

(I have searched for a solution but didn't find anyone that I can understand:-) )

Replies are listed 'Best First'.
Re: Simple Tkx loop question
by zentara (Cardinal) on Feb 23, 2010 at 11:31 UTC
    I don't do Tkx, but the thing you want to do is use a millisecond timer. Like
    my $timer = $mw->repeat( 3000, \&my_routine(); # will do it every 3 seconds Tkx::MainLoop(); exit;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
      Unfortunately it didn't work;
      bad option "repeat": must be cget or configure at Ikon.pl line 82.
      I guess that there's a equivalent for Tkx?
      The closest I got was http://www.mail-archive.com/tcltk@perl.org/msg00220.html . Maybe that's correct?
        You just gave some pseudo code, and so did I. I don't have Tkx running, nor have knowledge of it's exact syntax. You asked how do I get this running in the mainloop. The answer is a timer.... how Tkx implements timers is up to you to find out. Maybe google for "perl Tkx timer", the first hit shows how to do it.... they call it a Tkx::after

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku
Re: Simple Tkx loop question
by Khen1950fx (Canon) on Feb 24, 2010 at 06:46 UTC
    I followed zentara's advice and googled "perl Tkx timer". On my first hit, I found this. It's straight from the horse's mouth:).