[Pythonmac-SIG] coercing to text

Ned Deily nad at acm.org
Tue Dec 15 07:19:40 CET 2009


Adam Morris wrote:
>In Applescript, I would write the following:

> tell app "Pages" to tell front document to get its selection  -- text from
>      character x to character y

>>> app('Pages').documents[1].selection.get()

or just

>>> app('Pages').documents[1].selection()
app(u"/Applications/iWork 
'09/Pages.app").documents.ID(13779112).body_text.text[app.documents.ID(13
779112).body_text.characters[95]:app.documents.ID(13779112).body_text.cha
racters[1681]]

>tell app "Pages" to tell front document to get its selection as text  --
> "whatever is selected"

>>> app('Pages').documents[1].selection()()
u'Lorem ipsum dolor sit amet, [...]'

(Tested with Pages '09 and appscript 0.21)

-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list