擅长:python、mysql、java
<p>你的代码几乎没有问题。在</p>
<p><a href="https://docs.python.org/2/library/subprocess.html#subprocess.call" rel="nofollow noreferrer">^{<cd1>}</a></p>
<blockquote>
<p><em>Run the command described by args. Wait for command to complete, then return the returncode attribute</em>.</p>
</blockquote>
<p><a href="https://docs.python.org/2/library/subprocess.html#subprocess.Popen.wait" rel="nofollow noreferrer">^{<cd2>}</a>和<a href="https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate" rel="nofollow noreferrer">^{<cd3>}</a>也是阻塞函数。在</p>
<p>请改用<a href="https://docs.python.org/2/library/subprocess.html#subprocess.Popen.poll" rel="nofollow noreferrer">^{<cd4>}</a>。在</p>
<pre><code>subpr = subprocess.Popen(["python", codeFile, spacedout])
while subpr.poll() is None:
print("Still working...")
time.sleep(0.1)
</code></pre>
<p>因为您希望GUI线程能够响应,所以可以在另一个线程上启动子进程。像这样的东西</p>
^{pr2}$