Hi again, folks.

I'm trying to setup notifications from an embedded Quartz Composer file similar to
    http://developer.apple.com/technotes/tn2005/tn2146.html#TNTAG8

In my app delegate I have:
...
class QCPySightAppDelegate(NibClassBuilder.AutoBaseClass):
    def init(self):
        self = super(QCPySightAppDelegate, self).init()
        if not self:
            return None
        self._observeApp()
        return self
               
    def _observeApp(self):   
        NSNotificationCenter.defaultCenter().\
                             addObserver_selector_name_object_(self,
                                  "applicationWillTerminate:",
                                  NSApplicationWillTerminateNotification,
                                  None)
        NSNotificationCenter.defaultCenter ().\
                             addObserver_selector_name_object_(self,
                                  "applicationDidFinishLaunching:",
                                  NSApplicationWillTerminateNotification,
                                  None)
                                 
    def _unobserveApp(self):
        NSNotificationCenter.defaultCenter().removeObserver_name_object_(self, None, None) 

    def _observePatchController(self):
        """Sets observing for value changes on the image output"""
        self.patchController.addObserver_forKeyPath_options_context_(self, u"patch.Image.value", 0, None)
   
    def _unobservePatchController(self):
        self.patchController.removeObserver_forKeyPath_(self, u"patch.Image.value")
       
    def observeValueForKeyPath_ofObject_change_context_(keyPath, object, change, context):
        NSLog("Object Changed")
        NSLog(type(object))
                                 
    def applicationDidFinishLaunching_(self, notification):
        self._observePatchController()

    def applicationWillTerminate_(self, notification):
        """Cleanup here"""
        self._unobservePatchController()
        self._unobserveApp()
 ...

I get this error:

Traceback (most recent call last):
  File "/Volumes/Docs/Users/jonathan/svnCheckouts/main/scmac/trunk/QCPySight/QCPySightAppDelegate.py", line 54, in applicationDidFinishLaunching_
    self._observePatchController()
  File "/Volumes/Docs/Users/jonathan/svnCheckouts/main/scmac/trunk/QCPySight/QCPySightAppDelegate.py", line 39, in _observePatchController
    self.patchController.addObserver_forKeyPath_options_context _(self, u"patch.Image.value", None, None)

ValueError: depythonifying 'unsigned int', got 'NoneType'
2006-06-22 05:23:06.070 QCPySight[665] Exception raised during posting of notification.  Ignored.  exception: exceptions.ValueError: depythonifying 'unsigned int', got 'NoneType'

I wonder if I'm translating the code in the tech note properly re: adding an observer.  I'm pretty sure that I have the QC file setup properly and that the bindings are all kosher. 

Hoping that the code doesn't get unindented or otherwise weirdly broken by gmail....

--
Jonathan Saggau
jonathansaggau.com

This amusement engaged me so much that [friends] were obliged to force me from it; and thus it is with every inclination I give into, it continues to augment, till at length it becomes so powerful, that I lose sight of everything except the favorite amusement. - Rousseau
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to