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