How do you execute an OS X application (bundle) from Python?
Alex Martelli
aleaxit at yahoo.com
Fri Nov 5 02:41:31 EST 2004
More information about the Python-list mailing list
Fri Nov 5 02:41:31 EST 2004
- Previous message (by thread): How do you execute an OS X application (bundle) from Python?
- Next message (by thread): How do you execute an OS X application (bundle) from Python?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
has <has.temp2 at virgin.net> wrote: > dfh at forestfield.co.uk (David Hughes) wrote in message news:<70bb9f8d.0411040250.1f4ac1a at posting.google.com>... > > For example, in Python in a Nutshell, Alex Martelli shows how you can > > run a Windows (notepad.exe) or Unix-like (/bin/vim) text editor using > > os.spawnv(os.P_WAIT, editor, [textfile]) > > But how would you call the OS X text editor /Applications/TextEdit.app > > - which appears to be a whole directory inside /Applications? > > Using os.system to execute open is pretty simple, as other folks have > pointed out. ...but doesn't do the P_WAIT: just like using open at the Terminal prompt, it immediately continues with your code even as TextEdit is starting up. The idea of that snippet is to let the user edit a textfile for configuration, while until the user is done editing, then read the textfile etc etc. And it works file on the Mac with vi too. But apparently the P_WAIT is not implemented in the Mac version of Python like on the Windows version -- to *WAIT* until the app is done before continuing. So, it looks as if one will have to put in more complicated code in that case:-(. > replacement. Much improved, though unfinished, AE support is available > from my site: > > http://freespace.virgin.net/hamish.sanderson/appscript.html ... > from appscript import * > app('TextEdit.app').open(FSSpec(pathToFile)) OK, but how does one handle the *waiting*, so as to proceed only when TextEdit is done editing that document? "Spawning an external editor and waiting until the user is done using it before proceeding" is an important architectural pattern (well examined and analyzed in Raymond's "Art of Unix Programming", like many others). Ideally it should be the external editor of choice for the user; foisting vi on poor innocent machistas just because it's easy to wait for THAT and hard to wait for TextEdit would seem mean;-)... Alex
- Previous message (by thread): How do you execute an OS X application (bundle) from Python?
- Next message (by thread): How do you execute an OS X application (bundle) from Python?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list