Re: Perl-Gtk, DoEvents, Your thoughts?

Matthew M. Shannon said:
I've got a simple Perl-Gtk application that performs network (LWP)  queries.
My problem is whenever I make a Perl-Gtk call inside a
subroutine that is performing the network queries, I find it doesn't get
shown visibily until the entire subroutine ends.
In the Visual Basic world, you could use a DoEvents command to allow the
system to handle events during long running loops. Is there something  akin
to this in the Perl-Gtk world? Perhaps I'm completely looking in  the wrong
place and need to consider forking the network activity?

updating things in long loops is a rather common question.  it's covered in
the Gtk+ FAQ

but it's not so obvious there.

as for whether your I/O should be handled differently...  X (and unix for that
matter) apps have a long history of juggling lots of inputs in a single
the key is the select() system call.

Gtk/GLib have a high-level wrapper for this, called the IO Channel. 
basically, you get a file descriptor for your network connection (or anything
else) and create a "watch" for it; you register a callback with that watch,
and the callback is called whenever there is data available (or the pipe is
ready for writing, or there's an exception, etc).   this way you can do things
somewhat asynchronously in your app.

the GLib and Gtk C docs will be the canonical reference for this stuff.

muppet <scott asofyet org>

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