[Pythonmac-SIG] opening an application from python

Bob Ippolito bob at redivi.com
Fri Sep 2 10:59:43 CEST 2005


On Sep 2, 2005, at 1:29 AM, altern wrote:

> hi
>
> I am trying to launch a sound application (Pure Data) from a python
> program. For this I am using this code:
> #
> execdir = os.path.dirname(sys.argv[0])
> pdexc = os.path.join(execdir,
> "/Pd-0.38-4-extended-RC1.app/Contents/MacOS/Pd")
> arg = os.path.join(execdir, "audio.pd")
> os.spawnl(os.P_NOWAIT, pdexc, arg)
> # etc ...
>
> i need to pass arguments to the application, PD is a command line
> application so it can be run from the terminal and several start up
> flags can be passed.
>
> My problem is that it kind of runs but not properly. I get the process
> running, it is there if i do 'top' on the terminal. But the  
> application
> never fully opens. I was wondering if there is some problem with doing
> this from Python, or if i should be using some other command.

You should be using LaunchServices to launch the process with an open  
document event, directly or indirectly.  You can do that with PyObjC,  
or with Python 2.4's LaunchServices module, or with /usr/bin/open  
(man open).

-bob



More information about the Pythonmac-SIG mailing list