[Pythonmac-SIG] aeve app.make help

Bob Ippolito bob at redivi.com
Mon Dec 1 15:19:56 EST 2003


On Nov 30, 2003, at 1:11 AM, Winston Wolff wrote:

> Would somebody be able to help me with aeve?  I'm trying to automate 
> OmniGraffle along the lines of this example:
> 	http://www.designweenie.com/content.php/mappingWithGraffle01.php
> Eventually I want to generate various UML diagrams in OmniGraffle.  
> But first I'm having trouble just getting the hang of AppleScript via 
> Python.  I've never used AppleScript, but I've gone through the 
> AppleScript Language Guide.  So far I've successfully installed aeve 
> (0.0.4), the iCal example works, and now I want to do the equivalent 
> of this in Python:
>
> tell front document of application "OmniGraffle"
> 	set shp to make new shape at end of graphics with properties ¬
> 		{origin:{100, 100}, size:{20, 20}, draws shadow:false, name:"Circle"}
> end tell
>
> And this is what I've got so far:
>
> 	import aeve
> 	app = aeve.talkto('/Applications/OmniGraffle.app')
> 	from aeve.Applications import OmniGraffle as og
>
> 	origin 	= og.???._aereg_.iterObjectsForName("origin", 
> aekind="property", deep=True).next()
> 	size 	= og. .???.._aereg_.iterObjectsForName("size", 
> aekind="property", deep=True).next()
> 	name 	= og. .???.._aereg_.iterObjectsForName("name", 
> aekind="property", deep=True).next()
>
> 	shape = app.make(new=og.shape, with_properties={ origin:(100,100), 
> size:(20,20), name:"Circle" } )
>
> The problem seems to be this iterObjectsForName() call.  I don't know 
> what object to send this call to.  Can anybody help?

Any of the suite modules should do for "???", because the "deep" kwarg 
means that it will look in sibling suites.  You can try the aevegen 
script to generate a python package and take a look at the "generated 
python source".  You can even just pull the four character codes for 
the origin, size, and name properties and use those as the dictionary 
keys.  You might have to use lists instead of tuples for origin and 
size, or it might not work at all, I haven't tried that.

Alternatively, this might work (depends on the application, some let 
you do things like this).

import aeve
app = aeve.talkto('OmniGraffle')
from aeve.Applications import OmniGraffle as og
shape = app.make(new=og.shape)
shape.name = 'Circle'
shape.origin = [100, 100]
shape.size = [20, 20]

if not then this might work:

import aeve
app = aeve.talkto('OmniGraffle')
from aeve.Applications import OmniGraffle as og
shape = app.make(new=og.shape, with_properties={og.shape.origin: [100, 
100], og.shape.size: [20, 20], og.shape.name:'Circle'})

I can't really help you any more than this though.  I'm working on the 
next version of aeve, that has a lot of significant internal 
differences that should make "with_properties" easier (I'll probably 
special case it).  I don't plan on supporting 0.0.4 or earlier 
versions.

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20031201/5cfef9f9/smime.bin


More information about the Pythonmac-SIG mailing list