David Morley wrote:

> I can use (Python) appscript  reasonably well, if I know exactly what
> "components" I am looking for, e.g.,
>
> app('TextEdit').documents['Read Me'].paragraphs[1].get()
>
> But if I'm faced with a new application I don't know where to start.
> Is there any way to interactively explore what is available? Something
> like
>    dir(app('TextEdit')) -> [..., "documents", ...]
> to let me know that the app has document components
>    app('TextEdit').documents.keys() -> [..., "Read Me", ...]
> to let me know that "Read Me" is one of the documents
> and so on.

Appscript is basically an RPC+query-driven IPC mechanism with a bunch of vaguely OO-like syntactic sugar on top to make it look nice. Because it deals in queries, not proxy objects (a la COM, CORBA, etc.) and relies heavily on Python's so-called "magic methods" to do its thing, it doesn't play very well with standard Python introspection and documentation tools such as dir() and help(). Instead it provides its own fairly powerful set of tools:

1. ASDictionary exports appscript-style application dictionaries in HTML format

2. ASTranslate converts application commands from AppleScript to appscript syntax

3. Appscript's built-in help method [1] allows you to explore an application's dictionary and object model interactively, e.g.:

        te = app('TextEdit')
te.help() # show terminology for referenced object (in this case TextEdit's 'application' class) te.documents.name.help('-s') # show values of all document objects' name properties


And don't forget that you can retrieve referenced values via the get() command, e.g.:

te.documents.name.get() # Tip: this can also be written as te.documents.name()


BTW, if you haven't done so already, I recommend reading the appscript manual (available on the appscript site or in the .tar.gz file release) to get an idea of how appscript and Apple event IPC in general works. (If it's not clear, drop us a note and I'll try to improve it.) The manual includes a chapter on the available help options and how to use them.

HTH

has

[1] Requires ASDictionary to be installed first.
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to