1from AppKit import * 2from PyObjCTools import AppHelper 3 4class MyFormatter(NSFormatter): 5 def stringForObjectValue_(self, product): 6 if isinstance(product, (str, unicode)): 7 return product 8 return str(product) 9 10 def getObjectValue_forString_errorDescription_(self, value, upc, error): 11 print self, upc 12 13 if not upc: 14 print "No data" 15 return True, None, None 16 17 print "Have data" 18 return False, None, NSString.stringWithString_("Foo the %s"%("bar",)) 19 20AppHelper.runEventLoop() 21