Re: [Pyobjc-dev] Python as an AppleScript Replacement?
Brought to you by:
ronaldoussoren
From: Donovan P. <ds...@ma...> - 2003-03-02 09:30:06
|
On Saturday, March 1, 2003, at 11:46 PM, Peter Montagner wrote: > I may be missing something, but I thought that MacPython's OSA support > was limited to the AppleEvents level. AppleEvents are the low level > interapplication messaging protocol. The code would still be useful of > course, but it wasn't what I was thinking of (unless I'm missing > something). You *could* look up the 4 char AppleEvent codes for the > call you want manually and then send them and wait for a response, but > this is nothing like osa.getApp("Finder").empty_trash. It is the core > though. You are missing something -- gensuitemodule. gensuitemodule is a script that writes the python code which creates and sends the low level apple events for you, based on the high level AppleScript terminology. There are a few issues (resolvable) with using it to it's fullest potential on OS X: 1) It currently asks you to select an application with a Carbon file picker. The Carbon file picker exposed by python requires a type/creator mask, and won't let you pick application bundles. 2) It currently opens the resource fork of the application you chose and reads the binary data off disk, which it then parses to discover the english names and corresponding four character codes. The solution to these problems is to instead send the 'ascr' 'gdte' event directly to the application you wish to create a python module for, by addressing the application's four character code. If you are attempting to talk to a bundled application, the four character code is usually in the plist file inside the bundle. I have some experimental code which allows you to use gensuitemodule much more effectively on OS X by using the above apple event; however, I still haven't found a way to discover an application's four character code automatically. Unfortunately I am working on it in my spare time, but I will attempt to get a patch enhancing gensuitemodule for use on OS X into the sourceforge patch tracker sometime this week. Donovan |