don bright wrote: >I'm trying to detect when a process starts/stops. I'm >contemplating this excellent example from Apple, >'observing process lifetimes without polling' > >http://developer.apple.com/technotes/tn/tn2050.html > >However, it uses a function called >InstallApplicationEventHandler. I guess this is from >Carbon? The closest thing I can find in the python >source code is some files in _CarbonEvtModule.c: > >http://pxr.openlook.org/pxr/source/Mac/Modules/carbonevt/_CarbonEvtmodule.c > >However, I can't seem to figure out how or if I can >use it.
Python's Carbon extensions tend to wrap up Carbon ADTs as Python types, although some of the wrappings can be pretty counterintuitive. In this case, InstallEventHandler is a method on the EventTargetRef type, so you need to get one of those first. Quoting from here: http://developer.apple.com/documentation/Carbon/Conceptual/Carbon_Event_Manager/Tasks/chapter_3_section_4.html """ A similar macro, InstallApplicationEventHandler, needs no parameter to identify the application itself as the target; the call InstallApplicationEventHandler (handlerUPP, numTypes, typeList, userData, &handlerRef); is equivalent to theTarget = GetApplicationEventTarget(); InstallEventHandler (theTarget, handlerUPP, numTypes, typeList, userData, &handlerRef); """ So start with Carbon.CarbonEvt.GetApplicationEventTarget() and work from there. Another option would be to use use PyObjC, of course. HTH has -- http://freespace.virgin.net/hamish.sanderson/ _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig