擅长:python、mysql、java
<p>在一个项目中,我不得不启用一个模块来回调我的主窗口模块。主窗口视图的控制器启动一个新的子进程,并在程序终止后立即检索stdout out和回调。我是通过以下方式来解决这个问题的:(也许这对你的问题有帮助,但我并不完全理解)</p>
<p>主窗口模块:</p>
<pre><code>def run_program():
# consoleprocess is the second module that
# has to be able to do a callback.
# A new Instance of the ProcessRunner class is created.
self.progrunner = consoleprocess.ConsoleProcessRunner()
self.progrunner.cout.connect(self.cb_update_prog_output)
self.progrunner.quit.connect(self.cb_prog_terminated)
@QtCore.Slot(int)
@QtCore.Slot(str)
def cb_update_tv(self, data):
# your code goes here
pass
</code></pre>
<p>第二个模块(控制台进程):</p>
^{pr2}$