[pyar] Problema con Threads y Webkit

Mario Colque colquemario en gmail.com
Mar Ago 10 15:31:25 ART 2010


Gracias por las respuestas.
Pero me quede probando y me di cuenta de algo, que por lo menos yo, no
lo explico.

Porqué este código que lo base en el del recetario, funciona con la
opción 2 (.open()) y no con la 1 (.load_html_string()) ?

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
import threading

import gtk
import gtk.gdk

import webkit
import time

class molesto(threading.Thread):
    '''un thread que quiere molestar el main thread'''
    def __init__(self, ventana):
        threading.Thread.__init__(self)
        self.setDaemon(True)
        self.ventana = ventana
        self.browser = ventana.browser

    def run(self):
        '''metodo principal del thread, duerme un tiempo aleatorio y despues
        cambia el Label'''
        time.sleep(2)

        html = '<strong>Hola.</strong><br><small>Prueba<strong>
1</strong>, 2.</small>'

        gtk.gdk.threads_enter()
        #opción 1
        self.browser.load_html_string(html, 'file:/')
        #opción 2
#        self.browser.open('http://google.com')
        self.ventana.show_all()
        gtk.gdk.threads_leave()

class ventana(gtk.Window):
    '''ventana con un label, ninguna locura'''
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_default_size(640, 480)
        self.set_title('gtk con threads')
        self.browser = webkit.WebView()
        self.add(self.browser)

if __name__ == '__main__':
    gtk.gdk.threads_init()
    ventana = ventana()
    thread = molesto(ventana)
    thread.start()
    gtk.main()

Mi problema en si ya fué resuelto, pero haciendo algunas pruebas me
tope con esto.

Alguien sabe?

saludos!
-- 
Mario Colque

Staff Tuquito - www.tuquito.org.ar
Staff Garfio - www.garfio.org.ar
Web Developer - www.mariocolque.com.ar
Blog - blog.mariocolque.com.ar
LinkedIn - www.linkedin.com/in/mariocolque
http://colkito.mp
Skype - colkito
Twitter - @colkito
Identi.ca - @colkito



More information about the pyar mailing list