有人告诉我将此作为一个新问题发布。这是从 spawn 线程实例化新的 WX Python GUI的后续行动
我将以下代码实现到从衍生线程(Thread2)调用的脚本中
# Function that gets invoked by Thread #2
def scriptFunction():
# Code to instantiate GUI2; GUI2 contains wx.TextCtrl fields and a 'Done' button
p = subprocess.Popen("python secondGui.py", bufsize=2048, shell=True,stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# Wait for a response
p.wait()
# Read response
response = p.stdout.read()
# Process entered data
processData()
在运行 GUI2 的新进程上,我希望“完成”按钮事件处理程序将 4 个数据集返回给 Thread2,然后自行销毁(GUI2)
def onDone(self,event):
# This is the part I need help with; Trying to return data back to main process that instantiated this GUI (GUI2)
process = subprocess.Popen(['python', 'MainGui.py'], shell=False, stdout=subprocess.PIPE)
print process.communicate('input1', 'input2', 'input3', 'input4')
# kill GUI
self.Close()
目前,此实现在新进程中生成了另一个主 GUI。我想要做的是将数据返回到原始过程。谢谢。