示例#1
0
    # ObjCClass.get_instance_method = ObjCClass.get_method       # PYCHOK expected
    # parse_type_encoding           = split_encoding             # PYCHOK expected
    # set_instance_variable         = set_ivar                   # PYCHOK expected
    # unichar                       = unichar_t                  # PYCHOK expected
    # UniChar                       = UniChar_t                  # PYCHOK expected

    # if needed, previous NS...WindowMask names, deprecated ones are marked with D?
    # NSBorderlessWindowMask             = NSWindowStyleMaskBorderless              # PYCHOK D?
    # NSClosableWindowMask               = NSWindowStyleMaskClosable                # PYCHOK expected
    # NSFullScreenWindowMask             = NSWindowStyleMaskFullScreen              # PYCHOK D?
    # NSFullSizeContentViewWindowMask    = NSWindowStyleMaskFullSizeContentView     # PYCHOK D?
    # NSHUDWindowMask?                   = NSWindowStyleMaskHUDWindow               # PYCHOK D?
    # NSMiniaturizableWindowMask         = NSWindowStyleMaskMiniaturizable          # PYCHOK expected
    # NSMiniWindowMask                   = NSWindowStyleMaskNonactivatingPanel      # PYCHOK D?
    # NSResizableWindowMask              = NSWindowStyleMaskResizable               # PYCHOK expected
    # NSTexturedBackgroundWindowMask     = NSWindowStyleMaskTexturedBackground      # PYCHOK D?
    # NSTitledWindowMask                 = NSWindowStyleMaskTitled                  # PYCHOK D?
    # NSUtilityWindowMask                = NSWindowStyleMaskUtilityWindow           # PYCHOK D?
    # NSUnifiedTitleAndToolbarWindowMask = NSWindowStyleMaskUnifiedTitleAndToolbar  # PYCHOK D?
    # NSUnscaledWindowMask               = NSWindowStyleMaskUnscaled                # PYCHOK D? XXX

    # filter locals() for .__init__.py
    from pycocoa.utils import _all_exports  # PYCHOK expected
    __all__ = _all_exports(locals(), not_starts=('_', 'CFUNCTION', 'c_', 'kC'))


def _locals():
    '''(INTERNAL) For C{pycocoa.__main__.py} only'
    '''
    return globals()
    else:
        # printf('ns2Type(%r) -> %s', ns.objc_class, type(ns2py(ns)))
        _Type = ns2py

    # save the Python Type or ns2py convertor at the NS/Class
    # to expedite future conversions of such class instances
    ns.objc_class._Type = _Type
    return _Type(ns)


if __name__ == '__main__':

    from pycocoa.utils import _all_exports, _all_listing

    _all_exports(locals(), 'at', 'isAlias', 'isLink', 'isNone',
                 starts=('NS', 'ns'),
                 ends='2NS')
    _all_listing(__all__, locals())

    _ = '''% python3 -m pycocoa.nstypes

 nstypes.__all__ = tuple(
   nstypes.at is <class .at>,
   nstypes.isAlias is <function .isAlias at 0x10dd08560>,
   nstypes.isLink is <function .isLink at 0x10dd0e5f0>,
   nstypes.isNone is <function .isNone at 0x10dd0e680>,
   nstypes.ns2py is <function .ns2py at 0x10dd0f320>,
   nstypes.ns2Type is <function .ns2Type at 0x10dd0f3b0>,
   nstypes.NSAlert is <ObjCClass(NSAlert of 0x7fff9183b4a0) at 0x10d993b10>,
   nstypes.NSApplication is <ObjCClass(NSApplication of 0x7fff9183b5e0) at 0x10dc57d10>,
   nstypes.NSArray is <ObjCClass(NSArray of 0x7fff91ed5278) at 0x10d99e4d0>,
示例#3
0
    '''Return font traits as names.

       @param traits: Traits (C{FontTrait}C{s mask}).

       @return: Tuple of trait names (C{str}s).
    '''
    return tuple(n for n, m in sorted(FontTrait.items()) if traits & m)


NSFont._Type = _Types.Font = Font

if __name__ == '__main__':

    from pycocoa.utils import _all_exports, _all_listing

    _all_exports(locals(), starts=('Font', 'font'))
    _all_listing(__all__, locals())

    _ = '''% python3 -m pycocoa.fonts

 fonts.__all__ = tuple(
   fonts.Font is <class .Font>,
   fonts.FontError is <class .FontError>,
   fonts.fontfamilies is <function .fontfamilies at 0x10259b150>,
   fonts.fontnamesof is <function .fontnamesof at 0x102e97350>,
   fonts.Fonts.App=Font(name='Helvetica', family='Helvetica', size=12, weight=5),
              .Bold=Font(name='.AppleSystemUIFontBold', family='.AppleSystemUIFont', size=13, traits='Bold', weight=9),
              .BoldItalic=Font(name='.AppleSystemUIFontEmphasizedItalic', family='.AppleSystemUIFont', size=13, traits='Bold Italic', weight=9),
              .Italic=Font(name='.AppleSystemUIFontItalic', family='.AppleSystemUIFont', size=13, traits='Italic', weight=5),
              .Label=Font(name='.AppleSystemUIFont', family='.AppleSystemUIFont', size=10, weight=5),
              .Menu=Font(name='.AppleSystemUIFont', family='.AppleSystemUIFont', size=13, weight=5),
示例#4
0
    '''Get the name of the ObjC super-class of an object.

       @param objc: The object (C{Object} or L{Id_t}).

       @return: The object'ssuper-class name (C{str}).

       @raise ValueError: Invalid I{objc}, iff no I{dflt} provided.
    '''
    return get_classname(get_superclassof(objc), dflt=dflt)


if __name__ == '__main__':

    from pycocoa.utils import _all_exports, _all_listing

    _all_exports(locals(), starts='get_')
    _all_listing(__all__, locals())

    _ = '''% python3 -m pycocoa.getters

 getters.__all__ = tuple(
   getters.get_c_func_t is <function .get_c_func_t at 0x109165b00>,
   getters.get_class is <function .get_class at 0x109161dd0>,
   getters.get_classes is <function .get_classes at 0x1093a4680>,
   getters.get_classname is <function .get_classname at 0x1093a4710>,
   getters.get_classnameof is <function .get_classnameof at 0x1093a47a0>,
   getters.get_classof is <function .get_classof at 0x1093a4830>,
   getters.get_inheritance is <function .get_inheritance at 0x1093a49e0>,
   getters.get_ivar is <function .get_ivar at 0x1093a48c0>,
   getters.get_ivars is <function .get_ivars at 0x1093a4950>,
   getters.get_metaclass is <function .get_metaclass at 0x1093a4a70>,
    raise RuntimeError('%s %s %r vs %s' % (ns, '.uniqueID', u, t))


_Types.Window = NSWindow._Type = Window
_Types.MediaWindow = MediaWindow
_Types.TextWindow = TextWindow

if __name__ == '__main__':

    from pycocoa.utils import _all_exports, _all_listing

    _all_exports(locals(),
                 'BezelStyle',
                 'Border',
                 'MediaWindow',
                 'NSWindowDelegate',
                 'Screen',
                 'TextWindow',
                 starts=('AutoResize', 'autoResizes', 'ns', 'Window',
                         'window'))
    _all_listing(__all__, locals())

    _ = '''% python3 -m pycocoa.windows

 windows.__all__ = tuple(
   windows.AutoResize.HeightSizable=1<<4,
                     .MaxXMargin=1<<2,
                     .MaxYMargin=1<<5,
                     .MinXMargin=1,
                     .MinYMargin=1<<3,
                     .NotSizable=0,
示例#6
0
#   kPMReadGotZeroData            = -9788,  # read got zero bytes, but no error
# End of list
#   kPMLastErrorCodeToMakeMaintenanceOfThisListEasier = -9799

_Types.Paper = Paper
_Types.PaperCustom = PaperCustom
_Types.PaperMargins = PaperMargins
_Types.Printer = Printer

if __name__ == '__main__':

    from pycocoa.utils import _all_exports

    _all_exports(locals(),
                 'get_libPC',
                 'get_resolutions',
                 'libPC',
                 'Printer',
                 starts=('Paper', 'get_p'))

    for i, p in enumerate(get_printers()):
        print('%2s %s: ID %r, makemodel %r, URI %r' %
              (i + 1, p, p.ID, p.makemodel, p.deviceURI))

    d = get_printer()
    if d:
        print('\ndefault (%s) printer: %s...' % (d.isDefault, d))
        for a in ('name', 'ID', 'makemodel', 'isColor', 'location',
                  'psCapable', 'psLevel', 'isRemote', 'deviceURI',
                  'deviceDescription', 'description', 'PPD', 'resolution'):
            print(' %s.%s: %r' % (d, a, getattr(d, a)))
示例#7
0
       @raise TypeError: Unhandled, unexpected C{Type}.

       @see: Function L{py2NS}.
    '''
    try:
        return py.NS
    except AttributeError:
        return py2NS(py)


if __name__ == '__main__':

    from pycocoa.utils import _all_exports, _all_listing

    _all_exports(locals(), ends='2NS')
    _all_listing(__all__, locals())

# MIT License <https://OpenSource.org/licenses/MIT>
#
# Copyright (C) 2017-2020 -- mrJean1 at Gmail -- All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
示例#8
0
    if opened:
        raise TypeCodeError('encoding %s: %r' % ('unbalanced', bytes2str(encoding)))

    if code:  # final type code
        codes.append(_join(code))
    return codes


if __name__ == '__main__':

    from pycocoa.utils import _all_exports, _all_listing, \
                               bytes2repr, _Globals, printf

    _all_exports(locals(), 'PyObjectEncoding', 'TypeCodeError', 'c_void',
                 starts=('CG', 'CF', 'NS', 'ObjC', 'is', 'split_'),
                 ends='_t')

    _Globals.argv0 = ''

    def _c(ctype):
        return 'c_void' if ctype is c_void else ctype.__name__

    printf('%s ...', 'ctype2encoding', nl=1)
    i = 0
    for c, e in sorted((_c(c), e) for c, e in _ctype2encoding.items()):
        i += 1
        printf('%4s: %-9s -> %s', i, c, bytes2repr(e))

    printf('%s ...', 'encoding2ctype', nl=1)
    e = _encoding2ctype.copy()