PyQT4:从并行线程中的另一个python模块获取值

PyQT4:从并行线程中的另一个python模块获取值,python,module,pyqt4,python-multithreading,qthread,Python,Module,Pyqt4,Python Multithreading,Qthread,PyQT和QThread出现一些问题。 在QThread运行中使用来自另一个模块的方法时,我无法从中获取值。 我怎样才能得到它们 from PyQt4 import QtCore, QtGui import sys class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.initAnotherThread() self.setFixe

PyQT和QThread出现一些问题。 在QThread运行中使用来自另一个模块的方法时,我无法从中获取值。 我怎样才能得到它们

from PyQt4 import QtCore, QtGui
import sys


class MainWindow(QtGui.QMainWindow):
def __init__(self):

    QtGui.QMainWindow.__init__(self)
    self.initAnotherThread()
    self.setFixedSize(640, 360)
    self.setWindowTitle('Window')

    self.logText = QtGui.QTextEdit(self)
    self.logText.setReadOnly(True)
    self.logText.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
    self.logText.resize(460, 330)

    self.clickButton = QtGui.QPushButton('Click Button', self)
    self.clickButton.setFocusPolicy(QtCore.Qt.NoFocus)
    self.clickButton.setGeometry(470, 50, 160, 35)
    self.connect(self.clickButton, QtCore.SIGNAL('clicked()'), self.onButtonClick)

def initAnotherThread(self):
    self.updaterThread = anotherThread(self)

def onButtonClick(self):
    self.logText.clear()
    self.updaterThread.start()

class anotherThread(QtCore.QThread):
    def __init__(self, mw):
        super(anotherThread, self).__init__(mw)
        self.mw = mw

    def run(self):
        print "Another thread started"
        AnotherModule.anotherMethod()


if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    main = MainWindow()
    main.show()
    sys.exit(app.exec_())
在另一个模块中,我有下一个:

anotherMethod():
    x=0
    while x<100:
        x+=1

我应该怎么做才能从另一个Thermodule中获取x值?

您想在迭代时获取x值,还是在迭代后获取x值?在迭代时获取x值。这个答案似乎涵盖了以下内容: