Hi,
Threading does not work quite like that. You don't have to call threads enter and threads leave before every funtion call, only when you are making pygtk calls from another thread.
You would generally have:
if __name__ == '__main__': gtk.gdk.threads_init() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave()
Then you would have a callback from another thread:
def other_thread_has_data(): gtk.gdk.threads_enter() #do some gtk calls gobject.add_idle(do_the_real_work_since_win32_sucks) gtk.gdk.threads_leave()
You shouldn't have the enter/leave calls here. add_idle is thread safe and can be called at any point from any thread. You *will* need the enter /leave inside the idle function 'do_the_real_work_...' if that function calls gui functions.
Alternatively, use something like this:
def _idle_func(function, args, kw):
gtk.threads_enter()
try:
return function(*args, **kw)
finally:
gtk.threads_leave() def idle_add_lock(function, *args, **kw):
gobject.idle_add(_idle_func, function, args, kw)-- Tim Evans Applied Research Associates NZ http://www.aranz.com/ _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
