On Tue, 6 Mar 2001, Joakim Ziegler wrote:

> So this might be a simple question, but there aren't any docs, so I thought
> it would be ok to ask.
> 
> I'm making a small graphical frontend to some scripts and functions I already
> have in Python. These scripts use Python network and HTTP stuff to fetch
> data. How do I use that in combination with the GTK main loop so that the GUI
> doesn't freeze when I'm doing network stuff? Will I have to use threads? Does
> anyone have any sample code to point me to?

Pygtk exports the input_add() routine, which can be used to connect IO
handlers to the GTK main loop, which is what you need to do async IO.

As far as I can tell, most of the python networking library (httplib,
urllib, etc)seems to be synchronous (unless I have missed something).  So
you would either have to write your own async networking code, you may be
stuck with threads.

When doing any threaded programming, just remember that you need to
surround gtk calls in other threads with threads_enter() and
threads_leave(), otherwise bad things happen in gtk.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to