On 07/06/2010 03:53 PM, Jason Heeris wrote:
> Antoine Martin wrote:
>> I don't know of any examples unfortunately and I must admit that I spent
>> quite a bit of time getting to grips with it, but in the end it is
>> remarkably simple (much more simple than I first thought too - so don't
>> let that put you off):
>> import gtk.gdk
>> gtk.gdk.threads_init()
>
> This is not a good idea under Windows, sometimes it'll freeze here,
> other times... later.
Yes, sorry about that, forgot to mention that I do this in my code:
if not sys.platform.startswith("win"):
import gtk.gdk
gtk.gdk.threads_init()
>> if you need to interact with the GUI from that thread, do it via
>> gobject.idle_add()
>
> See, at this point I don't understand why Twisted gives me an
> advantage. I'm still using threads, I'm still using the problematic
> "idle_add"... what's different?
It means that most of your code is not using threads at all, only the
bits that are *slow* (and in my case these are fairly easy to spot:
execing and file-io) so you can call the gtk UI code from your network
callbacks or your network code from your UI callbacks without needing
any trickery.
I've lost track of your particular issue though, so maybe this is not
suitable for your use-case? How much slow work do you do compared to the
rest? (how many code paths, rather than raw amount)
Antoine
>
> - Jason
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/