• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Unwinding the containment hierarchy of a reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: where are the shell scripts ? (Applescript-users Digest, Vol 2, Issue 93)
  • Next by Date: Re: where are the shell scripts ? (Applescript-users Digest, Vol 2, Issue 93)
  • Previous by thread: RE: Unwinding the containment hierarchy of a reference
  • Next by thread: Duplicate with replacing
  • Index(es):
    • Date
    • Thread