[Pythonmac-SIG] creating a dictionary for an applescript app?

has hengist.podd at virgin.net
Wed Jun 20 14:03:26 CEST 2007


On 19 Jun 2007, at 22:23, tom wible wrote:

> btw, the aem complication increases my motivation to rewrite the  
> applescript...i only used a/s because ired & vdvhs are a/s-able,  
> and appscript solves that problem;-)

aem's easy enough to use if you know a little bit about how Apple  
events work, and you can easily extend its Application class to call  
user-defined subroutines with positional parameters, e.g.:

#!/usr/local/bin/python

import aem

class Applet(aem.Application):
	def initwithname(klass, name):
		return klass(aem.findapp.byname(name))
	initwithname = classmethod(initwithname)

	def callsub(self, name, *args):
		self.event('ascrpsbr', {'snam': name, '----': args}).send()


playRec = Applet.initwithname('playRec')
playRec.callsub('initRecList', False)
recList = playRec.callsub('listRecDict')


Adding convenience methods for calling standard event handlers (run,  
reopen, quit, etc.) and extending callsub to support labelled  
parameters wouldn't be too hard if you want to make a general-purpose  
module out of it.

HTH

has
-- 
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html



More information about the Pythonmac-SIG mailing list