python - Connecting thread signal to MainWindow -



python - Connecting thread signal to MainWindow -

i have 2 classes. 1 mainwindow class , other thread update progress bar, among other things.

to update progressbar using signal/slot construction this: (i show relevant code):

import threading pyqt4 import qtcore, qtgui, qt class mythread(threading.thread): mysignal = qtcore.pyqtsignal(int, int) def __init__(self,*args): threading.thread.__init__(self) class form1(qtgui.qmainwindow): def __init__(self, parent=none): qtgui.qwidget.__init__(self, parent) self.ui = ui_mainwindow() self.ui.setupui(self) ... ... @pyqtslot(int, int) def updateprogress(self, arg1, arg2): print "test argument1: ", arg1 print "test argument2: ", arg2 def my_function(self): mt = mythread(*args) mt.mysignal .connect(self.updateprogress) mt.start()

and getting not sure understand:

mt.mysignal .connect(self.updateprogress) typeerror: pyqtsignal must bound qobject, not 'mythread'

you need inherit qthread, not python thread. otherwise qobject-thread-ownership crucial signal/slots work across thread boundaries can't work it's magic.

python multithreading signals-slots

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -