小编Moh*_*sof的帖子

如何在python中终止qthread

我有GUI应用程序使用qwebview通过长循环进行Web自动化过程所以我使用QThread来做这个,但我不能终止线程,我的代码在下面

class Main(QMainWindow):
    def btStart(self):
        self.mythread = BrowserThread()
        self.connect(self.mythread, SIGNAL('loop()'), self.campaign_loop, Qt.AutoConnection)
        self.mythread.start()

    def btStop(self):
        self.mythread.terminate()

    def campaign_loop(self):
        loop goes here

class BrowserThread(QThread):
    def __init__(self):
        QThread.__init__(self)

    def run(self):
        self.emit(SIGNAL('loop()'))
Run Code Online (Sandbox Code Playgroud)

这个代码在启动线程时工作正常但是无法停止循环并且浏览器仍在运行,即使我向它调用close事件并且它从GUI中消失

python terminate pyside qthread

1
推荐指数
1
解决办法
6225
查看次数

如何将当前值传递给odoo中的向导

单击按钮时,我打开了一些向导,此向导在主模型的子模型中插入了一些值,因此我需要将一些数据从主模型发送到向导

数据包括当前 ID

openerp

0
推荐指数
1
解决办法
6219
查看次数

标签 统计

openerp ×1

pyside ×1

python ×1

qthread ×1

terminate ×1