import sys
class callback(QtCore.QThread):
def __init__(self, wtf):
QtCore.QThread.__init__(self)
self.wtf = wtf
print wtf, self.wtf
def run(self):
self.emit(QtCore.SIGNAL("msg(QString)"), QtCore.QString(self.wtf))
def __del__(self):
self.exiting = True
self.wait()
class MainWindow(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.text = QtGui.QPlainTextEdit(self)
self.callback_sender = callback("message")
self.callback_sender.start()
QtCore.QObject.connect(self.callback_sender,QtCore.SIGNAL("msg(QString)"),self.log)
def log(self, text):
self.text.appendPlainText(text)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
Комментариев нет:
Отправить комментарий