问题
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