阅读背景:

为什么在PyQt5中线程不工作?

来源:互联网 

Here is part of the code:

以下是部分代码:

    ...
    self.startButton.clicked.connect(self.conc_thread)


def conc(self):
    self.textField.clear()
    word=self.searchBox.text()
    path=r'D:\python1\wxPython\NYConc\Fiction'
    for filename in glob.glob(os.path.join(path, '*.txt')):
        try:
            file=open(filename, 'r')
            read=file.read()
            file.close()
            pattern=re.findall(r'.{40} '+word+r' .{40}', read)
            for i in pattern:
                self.textField.append(i)
        except:
            continue

def conc_thread(self):
    tg=threading.Thread(target=self.conc)
    tg.start()
    ...



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: