在 mac osx 上启动应用程序的多个进程 [英] Launch multiple process of an app on mac osx

查看:41
本文介绍了在 mac osx 上启动应用程序的多个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mac osx 10.9 上使用 python 2.7 来创建应用程序.这个应用程序以文件名作为参数,然后打开文件,并持续监控文件的变化,直到文件关闭.

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.

它对单个文件工作正常.我使用 py2app 和 platypus 将 python 代码 .py 文件转换为应用程序.

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.

推荐答案

这实际上不是 py2app 问题,而是由平台的工作方式引起的:当用户尝试打开与已经存在的应用程序关联的文件时运行系统不会启动应用程序的第二个实例,而是向已经运行的应用程序发送一个事件,告诉它打开新文件.

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.

要处理多个文件,您应该实现某种 GUI 事件循环(使用 PyObjC、Tk 等),该循环可用于接收当用户尝试为已运行的文件打开文件时发送的 OSX 事件申请.

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.

这篇关于在 mac osx 上启动应用程序的多个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆