[Pythonmac-SIG] AppleEvents in MacPython 2.3?
sb.list at sb.org
Mon Aug 11 16:25:37 EDT 2003
On 8/11/03 2:58 PM, "Paul Berkowitz" <berkowit at silcom.com> wrote:
> On 8/11/03 11:13 AM, "Stonewall Ballard" <sb.list at sb.org> wrote:
>> I spent many hours yesterday trying to figure out how to use the AppleScript
>> support that comes with MacPython 2.3, and wasn't able to make much
>> progress. Even a simple script like this:
>> tell application "TextEdit"
>> get word 1 of document 1
>> end tell
> No, this shouldn't really work in AppleScript either. There must be some
> sort of coercion going on. 'document' class in TextEdit has no 'word'
> element, nor does the AppleScript reserved 'word' know anything other than
> strings and Unicode text. (TextEdit, like most of the new Cocoa Apple apps,
> had its scripting implemented by people who knew next to nothing about
> AppleScript and did not study well-thought-out AppleScript dictionaries such
> as Tex-Edit Plus or BBEdit (sticking to text editors).)
> The correct script is:
> tell application "TextEdit"
> get word 1 of text of document 1
> end tell
> 'text' is a property of 'document' and 'word' is an element of 'text'.
> Try this version using Python - in fact how exactly are you trying to do
> AppleScript in Python? Or maybe stick with well-behaved apps to start
I guess this is just broken. I tried:
app = TextEdit.TextEdit()
# why is this necessary?
app.get( app.document(1).text.word(1) )
and it failed. with
AttributeError: _Prop_text instance has no attribute 'word'.
I can believe that this is just a messed up AS dictionary in TextEdit. The
object model shown by ScriptDebugger indicates that something in the
inheritance tree in TextEdit is broken.
Thanks for your help.
More information about the Pythonmac-SIG