[Pythonmac-SIG] Replacing AppleScript by Python
has
hengist.podd at virgin.net
Fri Oct 8 21:49:10 CEST 2004
Olivier Croquette wrote:
>I am trying to control an application, namely iView MediaPro.
>
>Until now, I knew only about AppleScript, so I started doing it in
>AppleScript. But it is really a pain, and I am really missing Python!
>
>Today, I discovered the MacPython project and also PyObjC.
>
>The problem I have, is following: I created a Python-iView interface
>thanks to the "Generate OSA suite" from the PythonIDE.
aetools, gensuitemodule, etc. are due for replacement. Use appscript instead:
http://freespace.virgin.net/hamish.sanderson/appscript.html
Get the latest version, 0.6.0. (Also requires aem and
osaterminology.) Appscript wraps up application object model
references - actually simple relational queries - in a layer of
terminology-driven syntactic sugar similar to standard Python OO
syntax. Much nicer to use than the clumsy gsm.
>There is visibly no exact equivalent between something like :
>
>tell application "iView MediaPro"
> tell catalog 1
> set mediaItem to import file MediaFile
> end tell
>end tell
Not used IMP myself so I'm kinda guessing here, but the following
should work (or at least come close):
from Carbon.File import FSSpec
from appscript import *
mediaItem = app('iView
MediaPro.app').catalogs[1].import(FSSpec('/path/to/MediaFile'))
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list