[Pythonmac-SIG] Ahoy!

Jack Jansen jack@oratrix.nl
Tue, 15 Feb 2000 10:49:44 +0100


Hmm, this all looks good. There's one reason why it could fail: if you have 
turned this into an applet, and you have the applet be started by retrospect 
(with an "activate") you have to turn off "argv emulation" on the resulting 
applet with EditPythonPrefs. This is so the initial AppleEvent isn't gobbled 
up by the AppleEvent code that creates sys.argv.

It's easy to check whether this is the problem: it doesn't occur if the applet 
is already running, in that case the event should come through fine.

> Hello, there.
> 	New to the list ... couldn't find an answer to this in the archives,
> so here it is. I'm trying to write an event handler in python to replace one
> written in AppleScript. Here's what I've got:
> 
> from MiniAEFrame import AEServer, MiniApplication
> 
> class EventHandler(AEServer, MiniApplication):
> 	def __init__(self):
> 		MiniApplication.__init__(self)
> 		AEServer.__init__(self)
> 		print "installing standard event handlers"
> 		self.installaehandler('aevt', 'oapp', self.open_app)
> 		self.installaehandler('aevt', 'quit', self.quit)
> 		self.installaehandler('ascr', 'psbr', self.retrospectEvent) 
> 		self.mainloop()
> 	
> 	def retrospectEvent(self, _object=None, _class=None, _type=None, **args):
> 		print _object, ":", _class, ":", _type
> 		for key in args.keys():
> 			print key + "==" + args[key]
> 
> 	def open_app(self, **args):
> 		pass
> 
> 	def quit(self, **args):
> 		self._quit()
> 
> if __name__ == '__main__':
> 		EventHandler()
> 
> But when an event actually gets sent from retrospect (the software I'm trying
> to capture events from), I get one of these in the Python window:
> 
> AE error:  (-608, 'noOutstandingHLE')
> in High Level Event: 'ascr' 'psbr'

--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm