Marco Islas Blog

PyGTK y Threads

Es facil, al inicio de tu aplicacion tendras que inicializar los threads, que son algo asi:

gtk.gdk.threads_init()
 
Esto lo tendras que hacer antes de iniciar algun thread. Y luego, al usar algun thread debes englobarlo dentro de

gtk.threads_enter()
thread.start_new(funcion, (arg1,arg2,argN))
gtk.threads_leave()
 
Solo recuerda que no debes manipular gtk fuera del thread en el que esta corriendo el ciclo principal (gtk.main_loop).

Si lo que necesitas es estar cachando informacion en un thread aparte y modificar la interfaz (ej. Leyendo un socket y mostrando informacion de cuanto llevas leido) entonces usa alguna bandera y modifica tu apariencia en el thread principal, de lo contrario tendras problemas con gobject y glib.
Trackback URI: http://islascruz.org/html/index.php?Blog/Trackback/id/526

Leave a Comment

Write the captcha code you are seeing.

Comment XML feeds: RSS | Atom

Recent Comments On Blog

avatar
el adlair on Almost 3 months
avatar
Eric on Franklin CDU-680 en Slackware Linux
avatar
markuz on June desktop
avatar
lesthack on June desktop
avatar
David Valdez on June desktop
avatar
markuz on Franklin CDU-680 en Slackware Linux
avatar
Eric on Franklin CDU-680 en Slackware Linux
avatar
allende on Christine 0.4.0 released!
avatar
markuz on Christine 0.4.0 released!
avatar
shakaran on Christine 0.4.0 released!
twitter logo
Galaxia Linux