我的 prog 中有一行用于启动我的程序的其他实例:
a=subprocess.Popen(__file__)
在 linux 下它工作正常。
但是在 osx 下,它并没有像它应该的那样创建一个新窗口(该程序是一个 Tkinter 程序),但它根本没有给出任何错误。 (我检查过 _file_ 实际上是正在运行的程序的正确名称,它是可执行的)
返回是这样的:
> pprint (vars(a))
{'_child_created': True,
'pid': 38865,
'returncode': None,
'stderr': None,
'stdin': None,
'stdout': None,
'universal_newlines': False}
有什么提示吗?
请您参考如下方法:
你那里有个尴尬的问题。你知道吗 ?您的窗口只是隐藏在之前创建的另一个窗口后面。
要看到这一点,请将最新创建的窗口显示在第一个窗口的前面,如下所示:
import Tkinter
import subprocess
if __name__ == "__main__":
try:
open('bluh_check')
except IOError:
open('bluh_check', 'w').close()
x = subprocess.Popen(['python', __file__])
print vars(x)
title = 'there'
else:
title = 'hi'
root = Tkinter.Tk()
root.title(title)
root.withdraw()
root.deiconify()
root.mainloop()
