Lars Damerow <[EMAIL PROTECTED]> writes:

> Hi all!
> I'm having problems doing the usual thing;  returning control periodically to
> GTK while doing a long-running operation.  I've been trying to put this in my
> operation's loop:
> 
>       while (events_pending()): mainiteration (FALSE)
> 
> ...and either function call causes the program to hang, not even responding to
> window close events.  I have to close it with a kill -9.

I had the same problem a few days ago, and I've even found a solution.

One solution is to put threads_leave and threads_enter around the loop:

        gtk.threads_leave()
        while gtk.events_pending():
            gtk.mainiteration(0)
        gtk.threads_enter()

I don't know whether this is the correct solution, though. It works for
me in Sketch, but Sketch is single threaded but runs on a thread enabled
Python interpreter.

Alternatively, one could modify pygtk and put the leave/enter into the
wrappers for gtk_main_iteration_do and gtk_events_pending as I outlined
in my last mail.

I think that it's really a bug in gtk. The function gtk_main() puts
leave/enter around the call to g_main_run while gtk_main_iteration and
gtk_events_pending don't do that for the calls to g_main_iteration and
g_main_pending respectively.

HTH

        Bernhard


-- 
Bernhard Herzog   | Sketch, a python based drawing program
[EMAIL PROTECTED]  | http://www.online.de/home/sketch/
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to