I wanted to try using the NSDistributedNotificationCenter to pass  
messages between two separate python programs running simultaneously,  
so to learn about doing this I created this class:

FILE: listener.py
------------------------------------------------------------------------ 
-------------------------
import Foundation

class GetNotes(object):

     def __init__(self):
         '''register for an NSNotification'''
         nc = Foundation.NSDistributedNotificationCenter.defaultCenter()
         nc.addObserver_selector_name_object_(self, 'getMyNotes:',  
'myNote', None)

     def getMyNotes_(self, note):
         print 'got a note!:', note.object
------------------------------------------------------------------------ 
-------------------------

then I created an instance of this class and tried sending a  
notification via the command line, expecting to see a print statement  
that the notification was received:

import Foundation as F
import listener
gn = listener.GetNotes()
nc = F.NSDistributedNotificationCenter.defaultCenter()
nc.postNotificationName_object_('myNote', None)

So far, no such luck.  Any suggestions?

Thanks,
Mike
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to