python pyqt4给线程传递参数

class PollTimeThread(QtCore.QThread):

    def __init__(self, parent=None, do_create_data=True):#do_create_data放在最后

        super(PollTimeThread, self).__init__(parent)

        self.create_data = do_create_data

    def run(self):

        if self.create_data:

                do something

                self.create_data = 0

        else:

                do otherthing

---------------------------------分割线-------------------------------------------------------------------------------

调用:

do something:

self.thread = PollTimeThread(self,1)

self.thread.setTerminationEnabled(True)

self.thread.update.connect(self.update)

self.thread.start()


do otherthing:

self.thread.start()

你可能感兴趣的:(python pyqt4给线程传递参数)