Re: Perl Gtk2 simple scheduling



On Sun, 19 Oct 2008 18:17:25 -0700 (PDT)
MICHAEL MCGINN <mmcginn rogers com> wrote:

Hi,

I have an existing perl Gtk2 application that will run a sub-process based on user initiation(button click) 
and it reports back to an output console as it progresses. This is a consistent activity that happens every 
hour or so.

I'd like to maintain the 'manual' initiation but provide an 'automatic-mode' and have it run the event at a 
pre-determined time (60-90 minute intervals).

What is the best way to do this with perl & Gtk2?

Regards,
Michael


Use a timer.  
Return 1 from the callback to keep the timer going.
Return 0 to end the timer.

I need to refresh (update) a window (in
fact a widget) every X seconds.

my $id = Glib::Timeout->add ($milliseconds, \&timeout_handler);

 sub timeout_handler {
    do_cool_stuff ();
    return $need_to_stay_installed;  # return 0 or 1 to kill/keep timer going
 }

http://gtk2-perl.sourceforge.net/doc/pod/Glib/MainLoop.html#integer_Glib_Timeout
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]