[Pythonmac-SIG] 'Hello World' the OSA Way
has
hengist.podd at virgin.net
Wed Feb 2 19:48:56 CET 2005
Hey,
Well, it works (with thanks to Jack and Bob for getting me this far;):
#!/usr/local/bin/python
from Carbon.Cm import OpenDefaultComponent
from OSA.OSA import OSAComponentInstance
from aem.types import Codecs
c=Codecs()
ascpt = '''
set s to "hello" & space & "world"
say s using "Zarvox"
return s
'''
ascr = OpenDefaultComponent('osa ', 'ascr')
osac = OSAComponentInstance(ascr)
print `c.unpack(osac.OSADoScript(c.pack(ascpt), 0L, 'TEXT', 0))`
# -> '"hello world"'
Sweet. A couple immediate questions for Jack and anyone else who knows:
- Do I need to close components manually after use, or is that all
done automatically?
- There's a bunch of OSAxxxx functions not currently implemented by
OSA.so - what's the deal with those? There's a few I've not grokked
yet, but I can see several that will be needed to build a
comprehensively featured alternative to Cocoa's wimpy NSAppleScript.
- Has anyone tested or used the OSA package, written any example
scripts, etc. yet? Or am I the first?
Ta,
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list