Re: how to handle other class event loop ?



On Sat, Sep 26, 2009 at 6:29 PM, silent <silent2600 gmail com> wrote:
hi, list
  when I add other Class(not gtk2::*) to programe,
and it has a event loop function like gtk_main(), let me call it "abc_main()",

how can run both gtk_main() and abc_main() ?

when the code run into gtk_main(), it will not return unless destroy
the "Window",

You could try calling your abc_main() from a Glib::Timeout [1] event,
assuming your abc_main() event loop is polite about returning control
back to Gtk2->main.  If not, then you might want to look at separate
processes or threads and communicating via pipes/sockets.

Example Glib::Timeout usage (taken from one of my scripts [2]):
Glib::Timeout->add( $timeout, \&subroutine, $sub_args );
# this is how you pass in multiple objects/variables
Glib::Timeout->add( 500, \&check_terminal, [$b_term, $b_term_label] );

Thanks,

Brian

[1] http://gtk2-perl.sourceforge.net/doc/pod/Glib/MainLoop.html
[2] http://tinyurl.com/ydj3btk



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