RE: Unwinding the containment hierarchy of a reference
RE: Unwinding the containment hierarchy of a reference
- Subject: RE: Unwinding the containment hierarchy of a reference
- From: has <email@hidden>
- Date: Thu, 10 Feb 2005 00:39:09 +0000
Scott Babcock wrote:
Regarding checking existence and creating filtered lists, here's an example:
As far as using strings as property and element names and
constructing filter clauses on the fly, that's trivial to do in
Python, e.g.:
#!/usr/bin/pythonw
from appscript import *
windowRef = app('System
Events').application_processes['TextEdit'].windows['Preferences']
wantElement = 'buttons'
wantName = 'Revert to Default Settings'
doesExist = getattr(windowRef, wantElement)[wantName].exists()
print doesExist
wantElement2 = 'groups'
filterProperty = 'size'
filterValue = [340, 109]
filterExp = getattr(its, filterProperty) == filterValue
filteredList = getattr(windowRef, wantElement2).filter(filterExp).get()
print filteredList
BTW, if you can maybe explain in more detail what your overall goals
are I'd be interested to know. At some point I'd like to add support
for querying a reference's property and element names
programmatically (right now only the built-in help system has access
to this info) which'll make this sort of advanced dynamic usage even
easier, so it'd help to know what folk might use it for.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden