• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10.1/pyobjc-45/2.6/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/CocoaBindings/ControlledPreferences/
1#
2#  FontNameToDisplayNameTransformer.py
3#  ControlledPreferences
4#
5#  Converted by u.fiedler on 04.02.05.
6#  with great help from Bob Ippolito - Thank you Bob!
7#
8#  The original version was written in Objective-C by Malcolm Crawford
9#  at http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
10
11from Foundation import *
12from AppKit import *
13
14class FontNameToDisplayNameTransformer(NSValueTransformer):
15    """
16    Takes as input the fontName of a font as stored in user defaults,
17    returns the displayed font name of the font to show to the user.
18    """
19    def transformedValueClass(cls):
20        return NSString
21    transformedValueClass = classmethod(transformedValueClass)
22
23    def allowsReverseTransformation(cls):
24        return False
25    allowsReverseTransformation = classmethod(allowsReverseTransformation)
26
27    def transformedValue_(self, aValue):
28        font = NSFont.fontWithName_size_(aValue, 12)
29        return font.displayName()
30
31
32