Re: Gtk, Python, and Threading.



On Tue, Dec 14, 2010 at 3:21 PM, John Stowers
<john stowers lists gmail com> wrote:
> On Tue, 2010-12-14 at 09:28 +0100, Tomeu Vizoso wrote:
>> On Mon, Dec 13, 2010 at 19:56, Robert Park <rbpark exolucere ca> wrote:
>> > I. Give. Up.
>>
>> I try to avoid threads at all in my python programs.
>
> I never have any trouble on Linux when mixing threading and pygtk. Are
> you seeing these problems using pygtk or PyGObject+introspection?

Introspection.

> [1] I typically use the gobject.idle_add(gobject.emit, "foo", bar, baz)
> idiom to communicate from threading.Thread derived objects back to the
> UI. On windows things also work well providing one enters/leaves before
> running the main loop.
>
> I don't bother with the threads_enter and threads_leave approach.

Yeah, I tried it both ways, and both produced identical results. The
thread was successfully able to execute in the background and
manipulate the liststore data while keeping the UI interactive for the
user, except that the entire thread somehow blocked, and required the
user to 'tickle' the interface with mouse clicks in order to progress
the execution of the thread. I even gutted the threading method to be
nothing but print statements and I still experienced this behavior.

As a relative noob to both gtk and threading, I'm not really sure
what's going on, but seemed to me as though the threading.Thread
object was somehow executing synchronously with the GTK main loop,
which just idles until you interact with it.


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