Threads y GUI
Radix00
radix00 en gmail.com
Lun Dic 4 23:43:55 CET 2006
ESTE ES EL CODIGO
--------------------------------------------------------------------------------------------------------------------------
#Dialogo de la ventana principal
from dialogs.dlgPrincipal import dlgPrincipal
import sys, signal, time,threading
#Librerias necesarias
from PyQt4 import QtCore, QtGui
class programa:
def __init__(self):
################################################
# CARGA DE LA APLICACION #
################################################
self.app = QtGui.QApplication(sys.argv)
self.MainWindow = QtGui.QMainWindow()
dlgPrincipal(self)
################################################
# SE CIERRA EL PROGRAMA #
# AL CERARSE LA ULTIMA VENTANA #
################################################
self.app.connect(self.app, QtCore.SIGNAL('lastWindowClosed()'),
self.app, QtCore.SLOT('quit()'))
self.tarea=threading.Thread(target=self.prueba,name='Prueba')
self.tarea.start()
################################################
# MUESTRA LA VENTANA #
################################################
self.MainWindow.show()
sys.exit(self.app.exec_())
def prueba(self):
for i in range(3):
self.ui.textBrowser.append('Hola'+str(i))
self.ui.textBrowser.reload()
print 'Hola'+str(i)
time.sleep(5)
#Arranca el programa
if __name__=='__main__':
pro = programa()
----------------------------------------------------------------------------------------------------------------------------------
ESTOS LOS ERRORES
---------------------------------------------------
QObject::connect: Cannot queue arguments of type 'QTextCursor'
QObject::startTimer: timers cannot be started from another thread
QObject::connect: Cannot queue arguments of type 'QSizeF'
QObject::connect: Cannot queue arguments of type 'QRectF'
QObject::startTimer: timers cannot be started from another thread
Más información sobre la lista de distribución Python-es