Ionutz Borcoman wrote:

Thanx. My example worked with this small modification:

if __name__ == "__main__":
    gtk.threads_init()
    gtk.threads_enter()
    test = Test()
    test.main()
    gtk.threads_leave()

Nothing else needed. Cool.

I was also been able to do what I've wanted with the idle event and no threads. Now I am wondering what's better to use: idle events or threads ? Any recommendations ?

It depends on what you need to do, and on what you are comfortable using. Threads are good if what you are doing is going to take a long time and can't be divided up into small chunks that can be executed in an idle callback. Even if something can be done in multiple idle handlers I find that it is *sometimes* easier to use a separate thread.


The primary disadvantage of threads is that synchronisation problems and race conditions can get very complex if you aren't careful. Use Python's 'Queue' module for everything; if your algorithm requires something more complicated than Queue then change your algorithm ;-)

--
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/

Reply via email to