子线程完成后,如何打开PySide面板?

时间:2018-11-25 01:54:53

标签: python python-2.7 pyside python-multithreading

我有一段代码必须在打开面板之前运行,这需要在子线程中执行,完成此线程后,我需要打开面板,该面板应在主面板中运行线程。

我尝试的解决方案是在子线程的末尾运行show()命令,但不是触发主线程中的面板打开,而是在子线程中将其打开并在打开后立即关闭。参见下面的示例。

那么有什么方法可以触发主线程中的面板从线程内打开?如果没有,那么在子线程结束后打开面板的正确方法是什么?

from PySide.QtGui import *
from PySide.QtCore import *
import threading

class Panel(QWidget):
    def __init__(self):
        super(Panel, self).__init__()
        thread = threading.Thread(target=self.run)
        thread.daemon = True
        thread.start()

    def run(self):
        self.show()

Panel()

0 个答案:

没有答案
相关问题