• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10.1/pyobjc-45/pyobjc/pyobjc-framework-Cocoa-2.5.1/Examples/AppKit/Formatter/
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