Launch multiple process of an app on mac osx

六月ゝ 毕业季﹏ 提交于 2019-12-10 19:47:44

问题


I am using python 2.7 on mac osx 10.9 for creating an app. This app takes file name as argument, and then opens the file, and keep monitoring the file for changes till file is closed.

It is working fine for a single file. I used, py2app and platypus for converting python code .py file to an app.

Limitation of it is, once an instance(process) of an app is started(by clicking on any file to open), file opens. But, simultaneously, I am not able to open two files at a time i.e. to launch to instance of an app. Through terminal, it is possible to launch multiple instance of an app.

Then, what should I do, to open multiple files at a time, by clicking on multiple files at a time through this app.


回答1:


This is not really a py2app problem, but caused by the way the platform works: when a user tries to open a file that's associated with an application that is already running the system doesn't start a second instance of the application but sends the already running application an event to tell it to open the new file.

To handle multiple files you should implemented some kind of GUI event loop (using PyObjC, Tk, ...) that can be used to receive the OSX events that are sent when a user tries to open a file for an already running application.



来源:https://stackoverflow.com/questions/22921549/launch-multiple-process-of-an-app-on-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!