PyQT: QDialog outside main thread?
-
Hi,
I'am not into threading that much and so might have a stupid question. I'am trying to build a Viewer, usable in a data flow like python framework. Means I want to create a QDialog showing me some results in my script but it should not kill the main thread but continuing my script when closed. Is this possible and has anyone a hint for me how to do it?
What I'am currently doing is this, but gives me the error:
QApplication::exec: Must be called from the main thread
@
from future import print_functionfrom PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtOpenGL import *from Viewer_UI import Ui_Dialog
from thread import start_new_thread
import sys
class Viewer(QDialog, Ui_Dialog):
def init(self, data, parent=None):
QDialog.init(self, parent)
self.setupUi(self)#assert isinstance(arrv, ArrayVector) self.data = data def process(self): # dummy worker process self.label.setText(QString(self.data)) self.finished.emit() finished = pyqtSignal()
def main(data):
window = Viewer(data)
window.show()
return qApp.exec_()def run(data, argv=sys.argv):
app = QtGui.QApplication(argv)
start_new_thread(main, (data, ))
@Thx