【发布时间】:2019-09-10 11:44:35
【问题描述】:
我使用 wxPython 创建一个父窗口“A”(一个 wx.Frame)。
在“A”中,我创建了一个子(同样是 wx.Frame)对话框式弹出窗口“B”。
每当我按下父级“A”中的给定按钮时,我都会调用此代码:
import windowB as bb
class windowA (wx.Frame):
... some other methods go here...
def on_data_setup(self, event):
os.remove("tmp.tmp")
popUpWindow = bb.popUp(None, title='Data Manager')
popUpWindow.Show()
while not os.path.exists("tmp.tmp"):
time.sleep(1)
with open("tmp.tmp","r") as ifh:
l = ifh.readlines()
print l
windowB 包含在另一个文件中,它看起来像:
class windowB (wx.Frame):
...
def on_exit(self,event):
with open("tmp.tmp","w") as ofh:
ofh.write("test")
self.Close()
这显然不是字,因为当我在父类中调用“睡眠”时,整个程序冻结 - 我需要杀死它,因为我也不能与孩子“B”互动:(。
另外,通过临时文件传递信息效率非常低。
关键是,当我关闭它时,我需要我的子/弹出窗口 B 将信息传递回父窗口 A (B)。我该如何实现呢? 谢谢!
【问题讨论】: