pycocoa

Package pycocoa |
[frames] | no frames]

# Package pycocoa

A basic, ctypes-based Python binding to the macOS Objective-C Cocoa runtime and several other macOS libraries.

This is the cocoa-python package by Phillip Nguyen (C) 2011, modified, extended, tested, documented and published with permission under both the MIT License and the original New BSD License.

# Installation

To install `pycocoa`, type `pip install pycocoa` or `easy_install pycocoa` in a terminal window. Alternatively, download `pycocoa-y.m.d.zip` from PyPI or GitHub, `unzip` the downloaded file, `cd` to directory `pycocoa-y.m.d` and type `python setup.py install`. To run the PyCocoa tests, type `python setup.py test` or `python test/run.py` before or after installation.

Examples cocoavlc.py and simple_VLCplayer.py require installation of the VLC App for macOS and the corresponding Python-VLC binding.

# Documentation

In addition to the pycocoa package, the distribution files contain several tests, some examples and the documentation (generated by Epydoc using command line `epydoc --html --no-private --no-source --name=pycocoa --url=... -v pycocoa`).

# Tests

The tests and examples have only been run with 64-bit Python 3.13.2, 3.12.7. 3.11.5 and 2.7.18 using Python-VLC 3.0.21, 3.0.18, 3.0.16, 3.0.12, 3.0.11, 3.0.10, 3.0.8, 3.0.6, 3.0.4 and 2.2.8 (with the compatible VLC App) on macOS 15.3.2 Sequoia (on `arm64` natively only), 14.7.3 Sonoma, 13.2 Ventura, 12.0.1 Monterey, 11.6.1 and 11.5.2 Big Sur (aka 10.16), 10.15.7 Catalina, 10.14.6 Mojave or 10.13.6 High Sierra. The tests run with and without `lazy import` in Python 3.

Python 3.13.2, 3.12.7 and 3.11.5 run on Apple Silicon (`arm64` natively), other Python versions run on Intel (`x86_64`) or Intel emulation (`"arm64_x86_64"`, see function pycocoa.machine), but only before macOS 15 Sequoia (see function pycocoa.segfaulty).

Previously, `pycocoa` was tested with 64-bit Python 3.10.0, 3.9.6, 3.8.6, 3.8.3, 3.8.1, 3.7.4-6, 3.6.5, 2.7.17 and macOS' 2.7.16. However, `pycocoa` has not been tested on iOS nor with 32-bit Python and does not work with PyPy nor with Intel(R) Python.

# Notes

All `pycocoa` source code has been statically checked with PyChecker, PyFlakes, PyCodeStyle (formerly Pep8) and McCabe using 64-bit Python 2.7.18 and with Flake8 using 64-bit Python 3.13.2 on macOS 15.3.2 Sequoia.

Some alternatives to `pycocoa` are (a) PyObjC, the most comprehensive Python to Objective-C bridge (no longer included in macOS' Python), (b) Rubicon-ObjC for Python 3.5+, taking advantage of Python's typing annotations, (c) PyGUI for macOS and (d) wxPython.

# Env variables

The following environment variables are observed by `pycocoa`:

- `PYCOCOA_LAZY_IMPORT` - see module lazily and variable isLazy.
- `PYCOCOA_LIBOBJC_NONATOMIC` - see module runtime.
- `PYCOCOA_OBJC_LOG` - see module runtime.
- `PYCOCOA_SEGFAULTY` - see function segfaulty.

plus during development:

- `PYCOCOA_FOR_DOCS` - for extended documentation by `epydoc`.
- `PYCOCOA_INIT__ALL__` - see module lazily.
- `PYTHONFAULTHANDLER` - see module faults.

# Licenses

Copyright (C) 2017-2025 -- 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.`

`THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`

__

Copyright (C) 2011 -- Phillip Nguyen -- All Rights Reserved.

`Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:`

`1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.`

`2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.`

`3. Neither the name of objective-ctypes nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.`

`THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.`

Version: 25.03.25

Submodules
pycocoa.__main__: Print pycocoa all public attributes, pycocoa version, Python release, etc. pycocoa.apps: Types App and Tile, wrapping ObjC `NSApplication` and `NSDocktile`. pycocoa.bases: (INTERNAL) Base classes for Python `Types`. pycocoa.colors: Types Color, ColorError, CMYColor, GrayScaleColor, HSBColor, RGBColor, TintColor and UIColor wrapping Cocoa's `NSColor` and `enum`-like constants CMYColors, GrayScaleColors, HSBColors, RGBColors, TintColor, TintColors, UIColors and all Colors accessible by color space acronym like `CMY`, `GS`, `RGB`, etc. pycocoa.deprecated: Deprecated classes, constants, functions, internals, etc. pycocoa.dicts: Types FrozenDict and Dict, wrapping ObjC `NS[Mutable]Dictionary`. pycocoa.faults: Handle uncaught `ObjC/NSExceptions` and other `fault`s similar to standard module `faulthandler` available since Python 3.3. pycocoa.fonts: Type Font, etc., wrapping ObjC `NSFont`. pycocoa.geometry: Types Point, Rect and Size, wrapping ObjC `NSPoint_t`, NSRect_t, `NSSize_t`. pycocoa.getters: `get_...` functions to obtain ObjC classes, methods, protocols, etc. pycocoa.internals: Mostly INTERNAL, private classes, functions, constants, etc. pycocoa.lazily: Lazily import `pycocoa` modules and attributes, based on lazy_import from Brett Cannon's modutil. pycocoa.lists: Type List, wrapping ObjC `NSMutableArray`. pycocoa.menus: Types Item, ItemSeparator, Menu and MenuBar, wrapping ObjC `NSMenuItem` and `NSMenu` and Keys. pycocoa.nstypes: ObjC classes `NS...` and conversions from `NS...` ObjC to Python instances. pycocoa.octypes: ObjC `..._t` type definitions and some additional `ctypes`. pycocoa.oslibs: Various ObjC and macOS libraries, signatures, constants, etc. pycocoa.panels: Types OpenPanel and SavePanel, wrapping ObjC `NSOpenPanel` and `NSSavePanel`. pycocoa.printers: Types Printer, Paper, PaperCustom and PaperMargins, wrapping ObjC `NSPrinter`, `PMPrinter`, `PMPaper` respectively `PMPaperMargins` plus several `get_...` print functions. pycocoa.pytypes: Conversions from `NS...` ObjC instances to Python. pycocoa.runtime: Classes `ObjCClass`, `ObjCInstance`, `ObjCMethod`, `ObjCSubclass`, etc. pycocoa.screens: Types Frame and Screen, wrapping ObjC `NSScreen`. pycocoa.sets: Types FrozenSet and Set, wrapping ObjC `NS[Mutable]Set`. pycocoa.strs: Type Str, wrapping ObjC `NSStr[ing]`. pycocoa.tables: Types Table and TableWindow, wrapping ObjC `NSTableView`, `NSWindow`. pycocoa.tuples: Type Tuple, wrapping (immutable) ObjC `NSArray`. pycocoa.utils: Private and public utility functions. pycocoa.windows: Types AutoResize, Window, MediaWindow, Screen, WindowStyle, wrapping ObjC `NSWindow`, etc.

Classes
| LazyImportError Raised if `lazy import` is not supported, disabled or failed.
| Adict A `dict` with key and attribute access to the items and callable to add items.
| AlertPanel Python Type to show an alert, wrapping ObjC `NSAlert`.
| Allocator_t ObjC `CFAllocatorRef` type.
| App Python `App` Type, wrapping an ObjC `NSApplication`.
| Array_t
| AutoResizeError `AutoResize` option error.
| BOOL_t ObjC `boolean` type.
| Block_t ObjC `block` type.
| BrowserPanel Python Type to show a URL or file.
| BuiltInScreen DEPRECATED on 2025.03.16, use `Screens.BuiltIn`.
| CFIndex_t
| CFRange_t ObjC `struct` with fields `loc[ation]` and `len[gth]` (both `CFIndex_t`).
| CGBitmapInfo_t
| CGDirectDisplayID_t
| CGError_t
| CGFloat_t
| CGGlyph_t
| CGPoint_t ObjC `struct` with fields `x` and `y` (both `CGFloat_t`).
| CGRect_t ObjC `struct` with fields `origin` and `size` (`NSPoint_t`, `NSSize_t`).
| CGSize_t ObjC `struct` with fields `width` and `height` (both `CGFloat_t`).
| CMYColor Color in the Cyan-Magenta-Yellow space.
| CTFontOrientation_t
| CTFontSymbolicTraits_t
| Cache2 DEPRECATED on 2025.02.15, to be removed.
| Class_t ObjC `Class` type, encoding b'#'.
| Color Base `Color` class wrapping `NSColor` objects, intended specifically to avoid fatal exceptions when accessing non-applicable `NSColor` attributes.
| ColorError `Color` issue.
| Data_t
| DeepestScreen DEPRECATED on 2025.03.16, use `Screens.Deepest`.
| Dict Python `dict` Type, wrapping an ObjC `NSMutableDictionary`.
| Dictionary_t
| ErrorPanel Python Type to show an `NSError` alert, wrapping ObjC `NSAlert`.
| ExternalScreen DEPRECATED on 2025.03.16, use `Screens.External`.
| Font Python `Font` Type, wrapping ObjC `NSFont`.
| FontError Font selection error.
| FontTraitError Font traits error.
| Frame A screen frame, wrapping ObjC NSRect_t.
| FrozenDict Python immutable `dict` Type, wrapping an (immutable) ObjC `NSDictionary`.
| FrozenSet Python `frozenset` Type, wrapping an immutable ObjC `NSSet`.
| GrayScaleColor Color in the Gray-Scale space.
| HSBColor Color in thecHue-Saturation-Brightness space.
| IMP_t ObjC `IMPlementation` type.
| Id_t ObjC `Id/self` type, encoding b'@'.
| Item Python menu Item Type, wrapping ObjC `NSMenuItem`.
| ItemSeparator Python menu ItemSeparator Type, wrapping ObjC `NSMenuItem.separatorItem`.
| Ivar_t ObjC `instance variable` type.
| LazyAttributeError Raised if an attribute can't be `lazily imported`.
| List Python `list` Type, wrapping an ObjC `NSMutableArray`.
| MainScreen DEPRECATED on 2025.03.16, use `Screens.Main`.
| MediaWindow Media window Python Type, wrapping ObjC `NSWindow/NSView`.
| Menu Python Menu Type, wrapping ObjC `NSMenu`.
| MenuBar Python MenuBar Type, wrapping ObjC `NSMenu`.
| Method_t ObjC `method` type.
| NSDecimal Optimized, Python `NSDecimalNumber` class.
| NSDouble_t
| NSExceptionError Python Error wrapping an `ObjC/NSException`.
| NSFloat_t
| NSInteger_t
| NSMakePoint ObjC `struct` with fields `x` and `y` (both `CGFloat_t`).
| NSMakeRange ObjC `struct` with fields `loc[ation]` and `len[gth]` (both `NSUInteger_t`).
| NSMakeRect ObjC `struct`, like NSRect_t with different signature and properties.
| NSMakeSize ObjC `struct` with fields `width` and `height` (both `CGFloat_t`).
| NSPoint_t ObjC `struct` with fields `x` and `y` (both `CGFloat_t`).
| NSRange_t ObjC `struct` with fields `loc[ation]` and `len[gth]` (both `NSUInteger_t`).
| NSRect4_t ObjC `struct`, like NSRect_t with different signature and properties.
| NSRect_t ObjC `struct` with fields `origin` and `size` (`NSPoint_t`, `NSSize_t`).
| NSSize_t ObjC `struct` with fields `width` and `height` (both `CGFloat_t`).
| NSStr Python wrapper for the ObjC `NS[Constant]String`.
| NSTimeInterval_t
| NSUInteger_t
| NumberType_t
| Number_t
| OSlibError Couldn't find or load a macOS `.dylib` library.
| ObjCBoundClassMethod Python wrapper for a bound ObjC class method, only to distinguish bound class from bound instance methods.
| ObjCBoundMethod Python wrapper for a bound ObjC instance method, an IMP_t.
| ObjCClass Python wrapper for an ObjC class.
| ObjCClassMethod Python class representing an unbound ObjC class method, only to distinguish class methods from instance methods.
| ObjCConstant Python wrapper for an ObjC constant.
| ObjCDelegate Register the `_NS_Delegate._ObjC` (sub)class and create an ObjCClass`(_NS_Delegate.__name__)`.
| ObjCInstance Python wrapper for an ObjC instance.
| ObjCMethod Python class representing an unbound ObjC instance method, actually an IMP_t.
| ObjCSubclass Python class creating an ObjC sub-class of an existing ObjC (super)class.
| ObjC_t Base type to pretty-print ctypes `c_void_p`.
| OpenPanel Python Type to select a file, wrapping ObjC `NSOpenPanel`.
| OptionFlags_t
| Paper Python `Paper` Type, wrapping an opaque ObjC `PMPaper`.
| PaperCustom Create a custom Paper.
| PaperMargins Python `PaperMargins` Type, wrapping an ObjC `PMPaperMargins`.
| Point Python Type, wrapping an ObjC `NSPoint_t`.
| Point2 Python Type, like Point, different signature.
| Printer Python `Printer` Type, wrapping ObjC `NSPrinter` and `PMPrinter`.
| Protocol_t ObjC `protocol` type.
| RGBColor Color in the Red-Green-Blue space.
| Rect Python Type, wrapping an ObjC NSRect_t.
| Rect4 Python Type, like Rect, but signature as ObjC NSRect4_t.
| RunLoop_t ObjC `CFRunLoopRef` type.
| SEL_t ObjC `SELector/cmd` type, encoding `b':'`.
| SavePanel Python Type to save a file, wrapping ObjC `NSSavePanel`.
| Screen Screen Python Type, wrapping ObjC NSRect_t.
| SegfaultError Error raised instead of SEGFAULT, see module pycocoa.faults.
| Set Python `set` Type, wrapping an ObjC `NSMutableSet`.
| Set_t
| Size Python Type, wrapping an ObjC `NSSize_t`.
| Size2 Python Type, like Size, different signature.
| Str Python `str` Type, wrapping (immutable) ObjC `NSStr[ing]`.
| StrAttd Python `str` Type, wrapping (immutable) ObjC `NSAttributedString`.
| String_t
| Struct_t ObjC `struct` type.
| Table Python rows and columns {Table} Type, wrapping an ObjC `NSTableView`.
| TableWindow Python Type for a vertically scrollable window, wrapping ObjC `NSWindow/NSScrollView`.
| TextPanel Scrollable text panel Python Type, wrapping ObjC `NSAlert`.
| TextWindow Scrollable text window Python Type, wrapping ObjC `NSWindow/NSView`.
| Tile Dock tile for an App, wrapping an ObjC `NSDockTile`.
| TimeInterval_t
| TintColor Dynamic color, adaptable to vibrancy and accessibility settings.
| Tuple Python `tuple` Type, wrapping an immutable ObjC `NSArray`.
| TypeCodeError Error in ObjC type encoding.
| TypeID_t
| TypeRef_t ObjC opaque type.
| UIColor Dynamic color for User-Interface elements, adaptable to vibrancy and accessibility settings.
| URL_t ObjC `URL` type.
| UniChar_t
| Union_t ObjC `union` type.
| UnknownPtr_t Unknown pointer.
| Unknown_t Unknown type.
| VoidPtr_t Same as `c_void_p`, but distinguishable from `c_void_p`.
| Window Basic window Python Type, wrapping ObjC `NSWindow`.
| WindowError Window error.
| WindowStyleError Window style error.
| at Acronym NSStr.
| c_ptrdiff_t
| c_struct_t Base type to pretty-print ctypes `Structures`.
| frozendict An immutable Python `dict` with key and attribute access to the items.
| module_property_RO DEPRECATED on 2025.02.09, use `proxy_RO`.
| objc_method_description_t ObjC `struct` with fields `name` and `types` (`SEL_t`, `c_char_p`).
| objc_property_attribute_t ObjC `struct` with fields `name` and `value` (both `c_char_p`).
| objc_property_t ObjC `property` Class.
| objc_super_t ObjC `struct` with fields `receiver` and `class` (`Id_t`, `Class_t`).
| proxy_RO Decorator for a lazy module `dict` or `Read-Only` module property.
| unichar_t

Functions
None2NS(py) Return the `NSNull` singleton for Python's `None`. |
SIGs_enabled(*sigs) Return the signals currently handled as `fault`. |
add_ivar(clas, name, ctype) Add an instance variable to an ObjC class, |
add_method(clas, name_, method, encoding) Add a method to an ObjC class. |
add_protocol(clas, protocol) Add a protocol to an ObjC class. |
add_subclass(Super, name, register=False) Create a new sub-class of a given super-class. |
app_title(title) Get/set the app title. |
aspect_ratio(width, *height, **Error_kwds) Compute the smallest, integer aspect ratio. |
autoResizes(*options) Return a combination of auto resize options, specified by name. |
bool2NS(py) Create an `NSBoolean` from a Python `bool`. |
bytes2NS(py) Create an `NSData` from Python `bytes`. |
bytes2repr(bytestr) Represent `bytes` or `str` as `b"..."`. |
bytes2str(bytestr, dflt=missing, **name) Convert `bytes`/`unicode` to `str` if needed. |
clipstr(bytestr, limit=50) Clip a string to the given length limit. |
closeTables() Close all tables. |
decimal2NS(py) Create an `NSDecimal` from a Python `Decimal`. |
dict2NS(py) Create an `NSMutableDictionary` from a Python `dict` or `frozendict`. |
dicts2NS(py) Create an `NS[Mutable]Dictionary` from a Python `dict` or `frozendict`. |
disable() Disable `fault` handling and uninstall the signal handlers installed by faults.enable, like the faulthandler module in Python 3.3 and later. |
drain(objc) Release all objects in an `NSAutoreleasePool` instance. |
enable(file=sys.stderr, **unused) Enable `fault` handling similar to the faulthandler module available in Python 3.3 and later. |
errorf(fmtxt, *args, **file_flush_nl_nt_argv0) Like printf, but writing to file=sys.stderr. |
exiting(status=None) Get/set the `exit` and `status` to use after `fault`s or uncaught `ObjC/NSException`s. |
flint(f) Return `int` for integer `float`. |
float2NS(py) Create an `NSDouble` instance from a Python `float` or `int`. |
fontFamilies(*prefixes) Yield the installed font families. |
fontNamesOf(family) Yield the available font names of a family. |
fontTraits(*traits) Return the traits mask for the named traits. |
fontTraitstrs(traits) Return the font trait names for a traits mask. |
fontfamilies(*prefixes) DEPRECATED on 25.03.13, use `fontFamilies`. |
fontnamesof(family) DEPRECATED on 25.03.13, use `fontNamesOf`. |
fontsOf(family, size=0, weight=None) Yield the available fonts of a family. |
fontsOf4(family) Yield the available fonts of a family. |
fontsof(family, **size_weight) DEPRECATED on 25.03.13, use `fontsOf`. |
fontsof4(family) DEPRECATED on 25.03.13, use `fontsOf4`. |
frozendict2NS(py) Create an `NSDictionary` from a Python `frozendict` or `dict`. |
frozenset2NS(py) Create an `NSSet` from a Python `frozenset` or `set`. |
gcd(a, b) Calculate the Greatest Common Divisor of a and b. |
generator2NS(py, frozen=True) Create an `NS[Mutable]Array` from a Python `generator`. |
getUncaughtExceptionHandler() Get the currently installed uncaught `ObjC/NSException` handler. |
get_c_func_t(encoding, codes=None) Get the `ctypes` function type for a given function signature. |
get_class(name) Get a registered ObjC class by name. |
get_classes(*prefixes) Yield all loaded ObjC classes with a name starting with one of the given prefixes. |
get_classname(clas, dflt=missing) Get the name of an ObjC class. |
get_classnameof(objc, dflt=missing) Get the name of the ObjC class of an object. |
get_classof(objc) Get the ObjC class of an object. |
get_inheritance(clas) Yield the inheritance of an ObjC class. |
get_ivar(objc, name, ctype=None) Get the value of an instance variable (ivar). |
get_ivars(clas, *prefixes) Yield all instance variables (ivar) of an ObjC class with a name starting with one of the given prefixes. |
get_lib(name) Find and load a `.dylib` library. |
get_libPC() DEPRECATED on 25.02.25, use `Libs.PrintCore`. |
get_lib_framework(name, services=`'``ApplicationServices``'`, version='') Load a `Frameworks services name.framework` library. |
get_libs() DEPRECATED on 25.02.25, use `Libs`. |
get_metaclass(name) Get a registered ObjC metaclass by name. |
get_method(clas, name) Get a method of an ObjC class by name. |
get_methods(clas, *prefixes) Yield all methods of an ObjC class with a name starting with one of the given prefixes. |
get_papers(*printers) Yield the papers available at the given printer(s). |
get_printer(*prefixes) Find a printer by name or by ID or get the default printer. |
get_printer_browser(server=None) Show the printer browser for the given server. |
get_printers(server=None) Yield all printers available at the given server. |
get_properties(clas_or_proto, *prefixes) Yield all properties of an ObjC class or protocol with a name starting with one of the given prefixes. |
get_protocol(name) Get a registered ObjC protocol by name. |
get_protocols(clas, *prefixes) Yield all protocols of an ObjC class with a name starting with one of the given prefixes. |
get_resolutions(*printers) Yield the resolutions supported by the given printer(s). |
get_selector(name_) Get an ObjC selector by name. |
get_selectorname_permutations(name_, leading=False) Yield all permutations of a Python-style selector name. |
get_selectornameof(sel) Get the name of an ObjC selector. |
get_superclass(clas) Get the ObjC super-class of an ObjC class. |
get_superclassnameof(objc, dflt=missing) Get the name of the ObjC super-class of an object. |
get_superclassof(objc) Get the ObjC super-class of an object. |
inst2strepr(inst, strepr, *attrs) Convert an instance's attributes, maintaining the order. |
int2NS(py, NS=None) Create an `NSNumber` from a Python `int` or `long`. |
isAlias(path) Resolve a macOS file or folder alias. |
isClass(objc) Check whether an object is an ObjC clas. |
isImmutable(objc, *immutableClasses, **raiser_name) Check that an ObjC object is an immutable class' instance. |
isLink(path) Resolve a file or folder link or alias. |
isMetaClass(objc) Check whether an object is an ObjC metaclass. |
isMutable(objc, *mutableClasses, **raiser_name) Check that an ObjC object is a mutable class' instance. |
isNone(obj) Return True if obj is `None, NSMain.nil, NSMain.Null`, etc. |
isObjCInstanceOf(objc, *Classes, **raiser_name) Check whether an ObjC object is an instance of some ObjC class. |
is_enabled(sig=None) Check whether `fault` handling is enabled, similar to the faulthandler module available in Python 3.3 and later. |
isinstanceOf(inst, *classes, **raiser_name) Check a Python instance' class. |
islistuple(inst) Is `inst`ance a `list` or `tuple`? |
iterable2NS(py, frozen=True) Create an `NS[Mutable]Array` from a Python `iterable`. |
iterbytes(bytestr) Iterate `bytes`, yielding each as `byte`. |
lambda1(arg) Inlieu of using lambda arg: arg. |
leaked2() Return the number of memory leaks. |
list2NS(py) Create an `NSMutableArray` from a Python `list` or `tuple`. |
listuple2NS(py) Create an `NS[Mutable]Array` from a Python `list` or `tuple`. |
logf(fmtxt, *args, **file_flush_nl_nt_argv0) Like printf, but writing to file=NSMain.stdlog. |
macOSver() Return the macOS release as `str`. |
macOSver2(n=2) Return the macOS release as 1-, 2- or 3-tuple of `int`s. |
machine() Return the `platform.machine` string, distinguishing Intel from emulating Intel on Apple Silicon (on macOS). |
map2NS(py, frozen=True) Create an `NS[Mutable]Array` from a Python `map`. |
name2objc(name_) Convert a (selector) name to `bytes` and ObjC naming rules. |
name2py(name_) Convert a (selector) name `str` and Python naming conventions. |
name2pymethod(name_) Convert a (selector) name to a valid Python callback method. |
ns2App(ns) Get the App instance from an `NSApplication` or an `NSNotification` instance. |
ns2Item(ns) Get the Python instance for an `NSMenuItem`. |
ns2NSType2(ns) Get the main `NS[Mutable]...` class and Python Type. |
ns2Type(ns) Convert an `NS...` ObjC object to an instance of the corresponding Python Type, capital T!. |
ns2TypeID2(ns, dflt=None) Get the `NS...` ObjC `TypeID`. |
ns2Window(ns) Get the Window instance for an ObjC `NSWindow` or `NSNotification` instance. |
ns2py(ns, dflt=missing) Convert an ObjC class' instance to the equivalent Python standard type's instance or wrapper and value. |
nsArray2listuple(ns, ctype=<class 'ctypes.c_void_p'>, typy=None) Create a Python `list` or `tuple` from an `NS[Mutable]Array`. |
nsArray2tuple(ns, ctype=<class 'pycocoa.runtime.ObjCInstance'>, typy=<type 'tuple'>) Create a Python `tuple` from an immutable `NSArray`. |
nsBoolean2bool(ns, dflt=missing) Create a Python `bool` from an `NSBoolean`. |
nsBundleRename(ns_title, match=`'``Python``'`) Change the bundle title if the current title matches. |
nsData2bytes(ns, dflt=`'````'`) Create Python `bytes` from `NSData`. |
nsDecimal2decimal(ns) Create a Python `Decimal` from an `NSDecimal`. |
nsDescription2dict(ns, **defaults) Create an immutable `dict` object with key and attribute access to items by name. |
nsDictionary2dict(ns, ctype_keys=<class 'ctypes.c_void_p'>, ctype_vals=<class 'ctypes.c_void_p'>, typy=None) Create a Python `dict` or `frozendict` from an `NS[Mutable|Frozen]Dictionary`. |
nsDictionary2items(ns) Yield the `(key, value)` items from an `NSDictionary`. |
nsException(name=None, reason=`'``not given``'`, **info) Create an `ObjC/NSException` instance. |
nsIter(ns, reverse=False, keys=False) Iterate over an `NS..` ObjC objects's keys, values or reverse values. |
nsIter2(ns, reverse=False, keys=False) Iterate over an `NS..` ObjC objects's keys or (reverse) values. |
nsLog(ns_fmt, *ns_args) Formatted ObjC write to the console. |
nsLogf(fmtxt, *args) Formatted write to the console. |
nsNull2none(ns) Return Python `None` for an `NS/CFNull` or `nil`. |
nsNumber2num(ns, dflt=missing) Create a Python `Decimal`, `int` or `float` from an `NSNumber`. |
nsOf(inst) Return the `.NS` ObjC object of a Python wrapper or Type instance. |
nsRaise(name=None, reason=`'``not given``'`, **info) Create an `NSException` and mimick `@throw NSException`. |
nsSet2set(ns, ctype=<class 'ctypes.c_void_p'>, typy=None) Create a Python `set` or `frozenset` from an `NS[Mutable]Set`. |
nsString2str(ns, dflt=None) Create a Python `str` or `unicode` from an `NS[Mutable]Str[ing]`. |
nsTextSize3(text, ns_font=None) Return the size of a multi-line text. |
nsTextView(text, ns_font, scroll=50) Return an `NSTextView` for the given text string. |
nsThrow(nsExc) Mimick ObjC's `@throw NSException` to raise an exception. |
nsURL2str(ns) Create a Python `str` from `NSURL` string. |
nsValue2py(ns, dflt=missing) Create a Python instance from an `NS[Concrete]Value`. |
printf(fmtxt, *args, **file_flush_nl_nt_argv0) Formatted print fmt % args with optional keywords. |
properties(inst) All property names and values. |
property2(inst, name) DEPRECATED on 25.02.16, to be removed. |
property_RO(method) Decorator for `Read_Only` class/instance property. |
py2NS(py) Convert (an instance of) a Python object into an instance of the equivalent `NS...` ObjC class: |
range2NS(py, frozen=True) Create an `NS[Mutable]Array` from a Python `range`. |
register_subclass(subclas) Register an ObjC sub-class. |
release(objc) Release an ObjC instance to be deleted, eventually. |
retain(objc) Preserve an ObjC instance from destruction. |
segfaulty() Return `True` if SegfaultErrors are raised to prevent certain SEGFAULTs, `False` if SEGFAULTs are not expected or `None` if unknown. |
send_message(objc, sel_name_, *args, **restype_argtypes) Send message to an ObjC object. |
send_super(objc, sel_name_, *args, **restype_argtypes) Send message to the super-class of an ObjC object. |
send_super_init(objc) Send 'init' message to the super-class of an ObjC object. |
set2NS(py) Create an `NSMutableSet` from a Python `set` or `frozenset`. |
setUncaughtExceptionHandler(handler, log=True, raiser=False) Install a callback to handle uncaught `ObjC/NSException`s. |
set_ivar(objc, name, value, ctype=None) Set an instance variable of an ObjC object. |
sets2NS(py) Create an `NS[Mutable]Set` instance from a Python `set` or `frozenset`. |
sortuples(iterable) DEPRECATED on 25.02.09, to be removed. |
split_emcoding2(encoding, start=0) Split the type encoding of a method signature into separate, single encodings and the combined encoding. |
split_encoding(encoding) Split a type encoding into separate type encodings. |
str2NS(py) Create an `NSStr` instance from a Python `str`. |
str2bytes(strbytes, dflt=missing, **name) Convert `strbytes` to `bytes`/`unicode` if needed. |
strs2NS(py, frozen=True) Create an `NS[Mutable]String` from a Python `str`. |
terminating(app, timeout=None) Set up a separate thread to terminate an NSApplication app by calling its `.terminate_` method at the given timeout in seconds. |
time2NS(py=None, since=1970) Create an `NSDate` instance from a timestamp. |
title2action(title) Convert a menu item `title` to a Python callback method name. |
tuple2NS(py) Create an immutable `NSArray` instance from a Python `tuple` or `list`. |
type2NS(py) Create the `NS...` ObjC object for a Python Type (or wrapper) instance. |
type2strepr(inst, strepr=<type 'str'>, **kwds) Represent a Python Type instance as `str` or `repr`. |
unicode2NS(py) Create an `NSStr` instance from a Python `unicode` string. |
url2NS(py, url2=None) Create an `NSURL` instance from a Python string. |
windowStyles(*styles) Return a combination of window styles, specified by name. |
z1000str(size, sep='_') Convert a size to string with 1_000's seperator. |
zSIstr(size, B=`'``B``'`, K=1024) Convert a size to string with SI-units suffix. |
zfstr(flt, prec=3) Format a `float` and strip trailing zero decimals. |

Variables
| pycocoa_abspath = ``'``..../PyC``...``
| version = ``'``25.3.25``'``
| AlertStyle = `AlertStyle.Critical`...``
| AutoResize = `AutoResize.HeightSizable=16 or 1<`...``
| BezelStyle = `BezelStyle.Circular`...``
| Border = `Border.Bezel`...``
| CGImageEncoding = ``'``{CGImage=}``'``
| CGPointEncoding = ``'``{CGPoint=dd}``'``
| CGRectEncoding = ``'``{CGRect={CGPoint=dd}{CGSize=dd}}``'``
| CGSizeEncoding = ``'``{CGSize=dd}``'``
| CMYColors = `CMYColors.Cyan=CMYColor(_NSTaggedPointerColor, nam`...``
| Colors = `Colors.CMY=CMYColo`...``
| FontDesign = `FontDesign.Default`...``
| FontTextStyle = `FontTextStyle.Body=`...``
| FontTrait = `FontTrait.Bold`...``
| FontWeight = `FontWeight.Black=12 or 3<`...``
| Fonts = `Fonts.App=Font.Helvetica(family=Helvetica, size=12, we`...``
| GrayScaleColors = `GrayScaleColors.Black=GrayScaleColor(_NSTagg`...``
| HSBColors = `HSBColors.NoneYet=None`
| Keys = `Keys.ACK=0`...``
| Libs = `{'CoreFoundation': <CDLL 'CoreFoundation.framework/Core`...``
| NO = `False`
| NSAcknowledgeCharacter = `6`
| NSAlert = `ObjCClass('NSAlert')`
| NSAlertDelegate = `<pycocoa.internals.proxy_RO object at 0x7f81`...``
| NSAlphaShiftKeyMask = `65536`
| NSAlternateKeyMask = `524288`
| NSAnyEventMask = `4294967295`
| NSApplication = `ObjCClass('NSApplication')`
| NSApplicationActivationPolicyAccessory = `1`
| NSApplicationActivationPolicyProhibited = `2`
| NSApplicationActivationPolicyRegular = `0`
| NSApplicationDefined = `15`
| NSApplicationDelegate = `<pycocoa.internals.proxy_RO object at `...``
| NSApplicationDidHideNotification = `c_void_p(140704673184176)`
| NSApplicationDidUnhideNotification = `c_void_p(140704673184272)`
| NSApplicationPresentationDefault = `0`
| NSApplicationPresentationDisableHideApplication = `256`
| NSApplicationPresentationDisableProcessSwitching = `32`
| NSApplicationPresentationHideDock = `2`
| NSApplicationPresentationHideMenuBar = `8`
| NSArray = `ObjCClass('NSArray')`
| NSAttributedString = `ObjCClass('NSAttributedString')`
| NSAutoreleasePool = `ObjCClass('NSAutoreleasePool')`
| NSBackSpaceCharacter = `8`
| NSBackTabCharacter = `25`
| NSBackingStoreBuffered = `2`
| NSBackingStoreNonretained = `1`
| NSBackingStoreRetained = `0`
| NSBellCharacter = `7`
| NSBezierPath = `ObjCClass('NSBezierPath')`
| NSBoolean = `NSNumber.numberWithBool_`
| NSBundle = `ObjCClass('NSBundle')`
| NSCancelButton = `0`
| NSCancelCharacter = `24`
| NSCarriageReturnCharacter = `13`
| NSCenterTextAlignment = `2`
| NSClearLineFunctionKey = `63289`
| NSColor = `ObjCClass('NSColor')`
| NSCommandKeyMask = `1048576`
| NSConcreteNotification = `ObjCClass('NSConcreteNotification')`
| NSConcreteValue = `ObjCClass('NSConcreteValue')`
| NSConstantString = `ObjCClass('NSConstantString')`
| NSControlKeyMask = `262144`
| NSData = `ObjCClass('NSData')`
| NSDataLineEscapeCharacter = `16`
| NSDate = `ObjCClass('NSDate')`
| NSDecimalNumber = `ObjCClass('NSDecimalNumber')`
| NSDefaultRunLoopMode = `_dllattr(_libAppKit, NSDefaultRunLoopMo`...``
| NSDeleteCharacter = `127`
| NSDeleteFunctionKey = `63272`
| NSDeviceControl1Character = `17`
| NSDeviceControl2Character = `18`
| NSDeviceControl3Character = `19`
| NSDeviceControl4Character = `20`
| NSDictionary = `ObjCClass('NSDictionary')`
| NSDockTile = `ObjCClass('NSDockTile')`
| NSDouble = `NSNumber.numberWithDouble_`
| NSDownArrowFunctionKey = `63233`
| NSEndFunctionKey = `63275`
| NSEndOfMediumCharacter = `25`
| NSEndOfTextCharacter = `3`
| NSEndOfTransmitBlockCharacter = `23`
| NSEndOfTransmitCharacter = `4`
| NSEnquiryCharacter = `5`
| NSEnterCharacter = `3`
| NSEnumerator = `ObjCClass('NSEnumerator')`
| NSError = `ObjCClass('NSError')`
| NSEscapeCharacter = `27`
| NSEventTrackingRunLoopMode = `_dllattr(_libAppKit, NSEventTrack`...``
| NSException = `ObjCClass('NSException')`
| NSF19FunctionKey = `63254`
| NSF1FunctionKey = `63236`
| NSFileHandlingPanelCancelButton = `0`
| NSFileHandlingPanelOKButton = `1`
| NSFileSeparatorCharacter = `28`
| NSFlagsChanged = `12`
| NSFloat = `NSNumber.numberWithDouble_`
| NSFloatEncoding = ``'``f``'``
| NSFont = `ObjCClass('NSFont')`
| NSFontBoldMask = `2`
| NSFontClarendonSerifsClass = `1073741824`
| NSFontClassMask = `4026531840`
| NSFontColorGlyphsMask = `8192`
| NSFontCompositeMask = `16384`
| NSFontCompressedMask = `512`
| NSFontCondensedMask = `64`
| NSFontDescriptor = `ObjCClass('NSFontDescriptor')`
| NSFontExpandedMask = `32`
| NSFontFreeformSerifsClass = `1879048192`
| NSFontItalicMask = `1`
| NSFontManager = `ObjCClass('NSFontManager')`
| NSFontModernSerifsClass = `805306368`
| NSFontMonoSpaceMask = `1024`
| NSFontNarrowMask = `16`
| NSFontNonStandardCharacterSetMask = `8`
| NSFontOldStyleSerifsClass = `268435456`
| NSFontOrnamentalsClass = `2415919104`
| NSFontPanel = `ObjCClass('NSFontPanel')`
| NSFontPosterMask = `256`
| NSFontSansSerifClass = `2147483648`
| NSFontScriptsClass = `2684354560`
| NSFontSlabSerifsClass = `1342177280`
| NSFontSmallCapsMask = `128`
| NSFontSymbolicClass = `3221225472`
| NSFontTransitionalSerifsClass = `536870912`
| NSFontUIOptimizedMask = `4096`
| NSFontUnboldMask = `4`
| NSFontUnitalicMask = `16777216`
| NSFontUnknownClass = `0`
| NSFontVerticalMask = `2048`
| NSFormFeedCharacter = `12`
| NSFunctionKeyMask = `8388608`
| NSGroupSeparatorCharacter = `29`
| NSHelpFunctionKey = `63302`
| NSHelpKeyMask = `4194304`
| NSHomeFunctionKey = `63273`
| NSHorizontalTabCharacter = `9`
| NSImage = `ObjCClass('NSImage')`
| NSImageView = `ObjCClass('NSImageView')`
| NSInt = `NSNumber.numberWithInt_`
| NSIntegerEncoding = ``'``l``'``
| NSIntegerMax = `9223372036854775807`
| NSJustifiedTextAlignment = `3`
| NSKeyDown = `10`
| NSKeyUp = `11`
| NSLayoutManager = `ObjCClass('NSLayoutManager')`
| NSLeftArrowFunctionKey = `63234`
| NSLeftTextAlignment = `0`
| NSLineFeedCharacter = `10`
| NSLineSeparatorCharacter = `8232`
| NSLong = `NSNumber.numberWithLong_`
| NSLongLong = `NSNumber.numberWithLongLong_`
| NSMain = `NSMain.Application=NSApplication(<Id_t at 0x7f8118e90`...``
| NSMenu = `ObjCClass('NSMenu')`
| NSMenuItem = `ObjCClass('NSMenuItem')`
| NSMutableArray = `ObjCClass('NSMutableArray')`
| NSMutableData = `ObjCClass('NSMutableData')`
| NSMutableDictionary = `ObjCClass('NSMutableDictionary')`
| NSMutableSet = `ObjCClass('NSMutableSet')`
| NSMutableString = `ObjCClass('NSMutableString')`
| NSNaturalTextAlignment = `4`
| NSNegativeAcknowledgeCharacter = `21`
| NSNewLineCharacter = `10`
| NSNotFound = `9223372036854775807`
| NSNotification = `ObjCClass('NSNotification')`
| NSNotificationCenter = `ObjCClass('NSNotificationCenter')`
| NSNull = `ObjCClass('NSNull')`
| NSNullCharacter = `0`
| NSNumber = `ObjCClass('NSNumber')`
| NSNumericPadKeyMask = `2097152`
| NSOKButton = `1`
| NSObject = `ObjCClass(_NSObject_)`
| NSOpenPanel = `ObjCClass('NSOpenPanel')`
| NSPageDownFunctionKey = `63277`
| NSPageLayout = `ObjCClass('NSPageLayout')`
| NSPageUpFunctionKey = `63276`
| NSParagraphSeparatorCharacter = `8233`
| NSPointEncoding = ``'``{CGPoint=dd}``'``
| NSPointZero = `NSPoint_t(0, 0)`
| NSPrintInfo = `ObjCClass('NSPrintInfo')`
| NSPrintOperation = `ObjCClass('NSPrintOperation')`
| NSPrintPanel = `ObjCClass('NSPrintPanel')`
| NSPrinter = `ObjCClass('NSPrinter')`
| NSRangeEncoding = ``'``{_NSRange=QQ}``'``
| NSRecordSeparatorCharacter = `30`
| NSRectEncoding = ``'``{CGRect={CGPoint=dd}{CGSize=dd}}``'``
| NSRightArrowFunctionKey = `63235`
| NSRightTextAlignment = `1`
| NSSavePanel = `ObjCClass('NSSavePanel')`
| NSScreen = `ObjCClass('NSScreen')`
| NSScrollView = `ObjCClass('NSScrollView')`
| NSSet = `ObjCClass('NSSet')`
| NSShiftInCharacter = `15`
| NSShiftKeyMask = `131072`
| NSShiftOutCharacter = `14`
| NSSizeEncoding = ``'``{CGSize=dd}``'``
| NSSpaceCharacter = `32`
| NSSquareStatusItemLength = `-2`
| NSStartOfHeadingCharacter = `1`
| NSStartOfTextCharacter = `2`
| NSStatusBar = `ObjCClass('NSStatusBar')`
| NSString = `ObjCClass('NSString')`
| NSSubstituteCharacter = `26`
| NSSynchronousIdleCharacter = `22`
| NSTabCharacter = `9`
| NSTableColumn = `ObjCClass('NSTableColumn')`
| NSTableView = `ObjCClass('NSTableView')`
| NSTableViewDashedHorizontalGridLineMask = `8`
| NSTableViewDelegate = `<pycocoa.internals.proxy_RO object at 0x`...``
| NSTableViewGridNone = `0`
| NSTableViewSolidHorizontalGridLineMask = `2`
| NSTableViewSolidVerticalGridLineMask = `1`
| NSTextAlignmentCenter = `2`
| NSTextAlignmentJustified = `3`
| NSTextAlignmentLeft = `0`
| NSTextAlignmentNatural = `4`
| NSTextAlignmentRight = `1`
| NSTextField = `ObjCClass('NSTextField')`
| NSTextView = `ObjCClass('NSTextView')`
| NSTextWritingDirectionEmbedding = `0`
| NSTextWritingDirectionOverride = `2`
| NSThread = `ObjCClass('NSThread')`
| NSTrackingActiveInActiveApp = `64`
| NSTrackingCursorUpdate = `4`
| NSTrackingMouseEnteredAndExited = `1`
| NSTrackingMouseMoved = `2`
| NSUIntegerEncoding = ``'``L``'``
| NSURL = `ObjCClass('NSURL')`
| NSUnitSeparatorCharacter = `31`
| NSUpArrowFunctionKey = `63232`
| NSValue = `ObjCClass('NSValue')`
| NSVariableStatusItemLength = `-1`
| NSVerticalTabCharacter = `11`
| NSView = `ObjCClass('NSView')`
| NSWindow = `ObjCClass('NSWindow')`
| NSWindowCloseButton = `0`
| NSWindowDelegate = `<pycocoa.internals.proxy_RO object at 0x7f8`...``
| NSWindowDocumentIconButton = `4`
| NSWindowMiniaturizeButton = `1`
| NSWindowStyleMaskClosable = `2`
| NSWindowStyleMaskMiniaturizable = `4`
| NSWindowStyleMaskResizable = `8`
| NSWindowStyleMaskTitled = `1`
| NSWindowStyleMaskUsual = `15`
| NSWindowStyleMaskUtilityWindow = `16`
| NSWindowToolbarButton = `3`
| NSWindowZoomButton = `2`
| NSZoneEncoding = ``'``{_NSZone=}``'``
| OBJC_ASSOCIATION = `OBJC_ASSOCIATION.ASSIGN`...``
| OBJC_ASSOCIATION_ASSIGN = `0`
| OBJC_ASSOCIATION_COPY = `771`
| OBJC_ASSOCIATION_COPY_NONATOMIC = `3`
| OBJC_ASSOCIATION_RETAIN = `769`
| OBJC_ASSOCIATION_RETAIN_NONATOMIC = `1`
| PanelButton = `PanelButton.Cancel`...``
| PyObjectEncoding = ``'``{PyObject=@}``'``
| RGBColors = `RGBColors.Blue=RGBColor(_NSTaggedPointerColor, nam`...``
| Screens = `(Screen(NSScreen, name='BuiltIn'), Screen(NSScreen, `...``
| TintColors = `TintColors.Blue=TintColor(NSDynamicSystemColor, n`...``
| UIColors = `UIColors.Control=UIColor(NSDynamicSystemColor, name`...``
| WindowStyle = `WindowStyle.Closable`...``
| YES = `True`
| c_void = `None` hash(x)
| isLazy = `None` hash(x)
| libAppKit = `<CDLL 'AppKit.framework/AppKit', handle 7fffa23edf`...``
| libCF = `<CDLL 'CoreFoundation.framework/CoreFoundation', handl`...``
| libCG = `<CDLL 'CoreGraphics.framework/CoreGraphics', handle 7f`...``
| libCT = `<CDLL 'CoreText.framework/CoreText', handle 7fffa23ee4`...``
| libFoundation = `<CDLL 'Foundation.framework/Foundation', handl`...``
| libPC = `<CDLL '/System/Library/Frameworks/ApplicationServices.`...``
| libobjc = `<CDLL 'libobjc.dylib', handle 7fffa23e3c6c at 7f8138`...``
| missing = `missing`

Function Details

### None2NS(py) |
Return the `NSNull` singleton for Python's `None`. Parameters: `py` - The value (`None`). Returns: The singleton (`NSNull`). Raises: `ValueError` - If py is not `None`.

### SIGs_enabled(*sigs) |
Return the signals currently handled as `fault`. Returns: An Adict with the `SIG*` name and value of the currently handled signals, if any.

### add_ivar(clas, name, ctype) |
Add an instance variable to an ObjC class, Parameters: `clas` - Class to add the ivar to (`ObjCClass/Subclass`). `name` - Name of the ivar (`str`). `ctype` - The ivar type code (`ctypes` or `encoding`). Returns: True if the ivar was added, False otherwise. Raises: `TypeCodeError` - Invalid ctype. Note: The ctype must be a `ctypes` type or a valid ObjC type encoding. See Also: The `_ObjCDeallocObserver` below.

### add_method(clas, name_, method, encoding) |
Add a method to an ObjC class. Parameters: `clas` - Class to add the method to (`ObjCClass/Subclass`). `name_` - Selector name (`str`). `method` - Decorated class or instance method (`callable`). `encoding` - Method signature (`encoding`). Returns: The method (IMP_t) if added, `None` otherwise. Raises: `TypeError` - If method is not a Python callable.

### add_protocol(clas, protocol) |
Add a protocol to an ObjC class. Parameters: `clas` - Class to add the protocol to (`ObjCClass/Subclass`). `protocol` - The `protocol` to add (`str` or Protocol_t instance). Returns: The protocol (Protocol_t) if added, `None` otherwise.

### add_subclass(Super, name, register=False) |
Create a new sub-class of a given super-class. Parameters: `Super` - The parent class (`str` or `Object`). `name` - The name of the sub-class (`str`). `register` - Optionally, register the new sub-class (bool). Returns: The sub-class (`Class_t`) if added, `None` otherwise. Note: After calling `add_subclass`, you MUST register the new sub-class with register_subclass, before using the new sub-class. New methods can be added after the sub-class has been registered, but any `ivar`s must be added BEFORE.

### app_title(title) |
Get/set the app title. Parameters: `title` - New title (`str`). Returns: Previous title (`str`).

### aspect_ratio(width, *height, **Error_kwds) |
Compute the smallest, integer aspect ratio. Parameters: `width` - The width (`float`, `int`, Size, 2-tuple (width, height), str("w:h") or `NSSize_t`). `height` - The height (`float` or `int`). Returns: 2-Tuple (width, height) as (`int`, `int`) or `None`. Example:
    >>> aspect_ratio(10, 15)
    (2, 3)
    >>> aspect_ratio(10.0, 15)
    (2, 3)
    >>> aspect_ratio(10, -15)
    (-2, 3)
    >>> aspect_ratio(-10, -15)
    (2, 3)
    >>> aspect_ratio(10.5, 15)
    (7, 10)
    >>> aspect_ratio(0, 15)
    ()

### autoResizes(*options) |
Return a combination of auto resize options, specified by name. Parameters: `options` - Option names (all positional), case-insensitive. Returns: Combined options (AutoResizes `mask`). Raises: `AutoResizeError` - One or more options are invalid.

### bool2NS(py) |
Create an `NSBoolean` from a Python `bool`. Parameters: `py` - The value (`int` or `bool`). Returns: The `NSMain.BooleanYES` or `.BooleanNO` singleton (`NSBoolean`).

### bytes2NS(py) |
Create an `NSData` from Python `bytes`. Parameters: `py` - The value (`bytes`). Returns: The ObjC instance (`NSData`). Raises: `TypeError` - If py not `bytes` or `str`. `RuntimeError` - If `len` vs `count` assertion failed.

### bytes2repr(bytestr) |
Represent `bytes` or `str` as `b"..."`. Parameters: `bytestr` - `bytes` or `str`.. Returns: Representation `b'...'` (`str`).

### bytes2str(bytestr, dflt=missing, **name) |
Convert `bytes`/`unicode` to `str` if needed. Parameters: `bytestr` - Original `bytes`, `str` or `unicode`. `dflt` - Optional, default return value. `name` - Optional name of bytestr argument. Returns: The `str` or dflt. Raises: `TypeError` - If neither `str` nor `bytes`, but only if no dflt is specified.

### clipstr(bytestr, limit=50) |
Clip a string to the given length limit. Parameters: `bytestr` - String (`bytes` or `str`). `limit` - Length limit (`int`). Returns: Clipped `bytes` or `str`.

### decimal2NS(py) |
Create an `NSDecimal` from a Python `Decimal`. Parameters: `py` - The value (`Decimal`, `float`, `int` or `str`). Returns: The value (`NSDecimal`). Raises: `TypeError` - If py not a `Decimal`, `float`, `int` or `str`. `ValueError` - Invalid decimal py.

### dict2NS(py) |
Create an `NSMutableDictionary` from a Python `dict` or `frozendict`. Returns: The ObjC instance (`NSMutableDictionary`). See Also: Function dicts2NS for further details.

### dicts2NS(py) |
Create an `NS[Mutable]Dictionary` from a Python `dict` or `frozendict`. Parameters: `py` - The value (`dict` or `frozendict`). Returns: The ObjC instance (`NSMutableDictionary` or immutable `NSDictionary`). Raises: `RuntimeError` - If `len` vs `count` assertion failed. `TypeError` - If py is not a `dict` or `frozendict`. See Also: Functions dict2NS and frozendict2NS.

### disable() |
Disable `fault` handling and uninstall the signal handlers installed by faults.enable, like the faulthandler module in Python 3.3 and later. Returns: `None`.

### drain(objc) |
Release all objects in an `NSAutoreleasePool` instance. Returns: The number of `ObjC` objects cleared. Note: `NSAutoreleasePool.drain` invokes the `dealloc` method only for the pool itself, not for any of the objects held/allocated in the pool.

### enable(file=sys.stderr, **unused) |
Enable `fault` handling similar to the faulthandler module available in Python 3.3 and later. Try to install handlers for the `SIGABRT`, `SIGBUS`, `SIGFPE`, `SIGILL` and `SIGSEGV` signals to dump a an ObjC call stack and Python traceback to `file`. Raises: `TypeError` - File `file` doesn't have callable `write` and `flush` attributes. See Also: `NSMain.stdlog`.

### exiting(status=None) |
Get/set the `exit` and `status` to use after `fault`s or uncaught `ObjC/NSException`s. Parameters: `status` - The exit "door" and status code to be used (`small int`) or `None` to leave unchanged. A negative `status` invokes `os._exit(abs(status))` to terminate without normal exit processing, while a non-negative `status` uses `sys.exit(status)` after a `fault`. Returns: The previously set `exiting` code (`int`). Note: The `faulthandler` module in Python 3.3 and later ignores all `exiting` settings.

### float2NS(py) |
Create an `NSDouble` instance from a Python `float` or `int`. Parameters: `py` - The value (`float` or `int`). Returns: The ObjC instance (`NSDouble`). Raises: `TypeError` - If py not a `float` or `int`.

### fontFamilies(*prefixes) |
Yield the installed font families. Parameters: `prefixes` - No, one or more font family names to match (`str`-s). Returns: Each font family name (`str`).

### fontNamesOf(family) |
Yield the available font names of a family. Parameters: `family` - Generic font name (`str`), like "Times" or "Helvetica". Returns: The name (`str`) of each font.

### fontTraits(*traits) |
Return the traits mask for the named traits. Parameters: `traits` - Trait names (`str`s), case-insensitive. Returns: Combined traits (`mask`). Raises: `FontTraitError` - One or more traits are invalid or incompatible, mutually exclusive.

### fontTraitstrs(traits) |
Return the font trait names for a traits mask. Parameters: `traits` - The traits (`mask`). Returns: Tuple of trait names (`str`s).

### fontsOf(family, size=0, weight=None) |
Yield the available fonts of a family. Parameters: `family` - Generic font name (`str`), like "Times" or "Helvetica". `size` - The point size (`int`), zero for any. `weight` - The book weight (`int`), `None` for any. Returns: A (Font) instance for each family font. Raises: `ValueError` - Invalid weight.

### fontsOf4(family) |
Yield the available fonts of a family. Parameters: `family` - Generic font name (`str`), like "Times" or "Helvetica". Returns: 4-Tuple (fontname, attributes, weight, traits) of (`str`, `str`, `int`, `mask`) for each family font.

### frozendict2NS(py) |
Create an `NSDictionary` from a Python `frozendict` or `dict`. Returns: The ObjC instance (`NSDictionary`, immutable). See Also: Function dicts2NS for further details.

### frozenset2NS(py) |
Create an `NSSet` from a Python `frozenset` or `set`. Returns: The ObjC instance (`NSSet`, immutable). See Also: Function sets2NS for further details.

### gcd(a, b) |
Calculate the Greatest Common Divisor of a and b. Unless b==0, the result will have the same sign as b (so that when b is divided by it, the result comes out positive).

### generator2NS(py, frozen=True) |
Create an `NS[Mutable]Array` from a Python `generator`. Parameters: `py` - The value (`generator`). `frozen` - If `True`, return an immutable `NSArray`, otherwise an `NSMutableArray` (`bool`). Returns: The ObjC instance (`NSMutableArray` or immutable `NSArray`). Raises: `TypeError` - If py not a `generator`.

### getUncaughtExceptionHandler() |
Get the currently installed uncaught `ObjC/NSException` handler. Returns: The installed handler (`callable`) or `None` if no handler was or couldn't be installed (like on macOS 12.0.1 Monterey, for example).

### get_c_func_t(encoding, codes=None) |
Get the `ctypes` function type for a given function signature. Parameters: `encoding` - Type encoding of the signature (`str` or `bytes`). `codes` - The individual type codes (`type encoding`[]) Note: The signature encoding is a `str` or `bytes`, not unicode and codes is a list of the individual type encodings, limited to basic type encodings and pointers to basic type encodings. Does not handle `array`s, `bitfield`s, arbitrary `struct`s and `union`s. If keyword codes is not supplied, it will be created from the signature by split_encoding, not split_emcoding2.

### get_class(name) |
Get a registered ObjC class by name. Parameters: `name` - The class name (`str`). Returns: The class (Class_t) if found, `None` otherwise.

### get_classes(*prefixes) |
Yield all loaded ObjC classes with a name starting with one of the given prefixes. Parameters: `prefixes` - No, one or more class names to match (`str`-s). Returns: For each class yield a 2-tuple (name, class) where name is the class name and class is the ObjC Class_t object.

### get_classname(clas, dflt=missing) |
Get the name of an ObjC class. Parameters: `clas` - The class (Class_t). Returns: The class name (`str`). Raises: `SegfaultError` - See function segfaulty. `ValueError` - Invalid clas, iff no dflt provided.

### get_classnameof(objc, dflt=missing) |
Get the name of the ObjC class of an object. Parameters: `objc` - The object (`Object` or Id_t). Returns: The object's class name (`str`). Raises: `SegfaultError` - See function segfaulty. `ValueError` - Invalid objc, iff no dflt provided.

### get_classof(objc) |
Get the ObjC class of an object. Parameters: `objc` - The object (`Object` or Id_t). Returns: The object's class (Class_t) if found, `None` otherwise.

### get_inheritance(clas) |
Yield the inheritance of an ObjC class. Parameters: `clas` - Class (Class_t). Returns: The parent classes (Class_t), in bottom-up order.

### get_ivar(objc, name, ctype=None) |
Get the value of an instance variable (ivar). Parameters: `objc` - The object (`Object` or Id_t). `name` - The instance variable name (`str`). `ctype` - The instance variable type (`ctypes`), Returns: The ivar value (`any`) if found, `None` otherwise.

### get_ivars(clas, *prefixes) |
Yield all instance variables (ivar) of an ObjC class with a name starting with one of the given prefixes. Parameters: `clas` - The class (Class_t). `prefixes` - No, one or more ivar names to match (`str`-s). Returns: For each ivar yield a 4-tuple (name, encoding, ctype, ivar) where name is the ivar name, encoding is the ivar's type encoding, ctype is the ivar's `ctypes` type and ivar is the Ivar_t object.

### get_lib(name) |
Find and load a `.dylib` library. Parameters: `name` - The library base name (`str`). Returns: The library (`ctypes.CDLL`). Raises: `OSlibError` - No `name.dylib` library found. Note: Private attribute `._name` shows the library path.

### get_lib_framework(name, services=`'``ApplicationServices``'`, version='') |
Load a `Frameworks services name.framework` library. Parameters: `name` - Library base name (`str`). `services` - Services framework base name (`str`). `version` - `Framework/Versions/version`, overriding `'Current'` (`str`). Returns: The library (`ctypes.CDLL`). Raises: `OSlibError` - No `name.framework` library found. Note: Private attribute `._name` shows the library path. Example: get_lib_framework('PrintCore') get_lib_framework('Metadata', services='CoreServices')

### get_metaclass(name) |
Get a registered ObjC metaclass by name. Parameters: `name` - The metaclass (`str`). Returns: The metaclass (Class_t) if found, `None` otherwise.

### get_method(clas, name) |
Get a method of an ObjC class by name. Parameters: `clas` - Class (Class_t). `name` - Method name (`str`). Returns: The method (Method_t) if found, `None` otherwise.

### get_methods(clas, *prefixes) |
Yield all methods of an ObjC class with a name starting with one of the given prefixes. Parameters: `clas` - The class (Class_t). `prefixes` - No, one or more method names to match (`str`-s). Returns: For each method yield a 4-tuple (name, encoding, resargtypes, method), where name is the method name, encoding is the type encoding of the method signature including the return type, resargtypes the `ctypes` signature, a `list`list of the argtypes preceeded by the restype and method the Method_t object.

### get_papers(*printers) |
Yield the papers available at the given printer(s). Parameters: `printers` - No, one or more printers (Printers). Returns: Each paper (Paper).

### get_printer(*prefixes) |
Find a printer by name or by ID or get the default printer. Parameters: `prefixes` - No, one or more printer names or IDs to match (`str`s). Returns: The printer (Printer) or `None` if none found.

### get_printer_browser(server=None) |
Show the printer browser for the given server. Parameters: `server` - Print server (`PMServer`) or `None` for this server, the localhost. Returns: Printers (`dict`) or `None`.

### get_printers(server=None) |
Yield all printers available at the given server. Parameters: `server` - Print server (`PMServer`) or `None` for this server, the localhost. Returns: Each printer (Printer).

### get_properties(clas_or_proto, *prefixes) |
Yield all properties of an ObjC class or protocol with a name starting with one of the given prefixes. Parameters: `clas_or_proto` - The class or protocol (Class_t or Protocol_t). `prefixes` - No, one or more property names to match (`str`-s). Returns: For each property, yield a 3-tuple (name, attributes, setter, property) where attributes is a comma-separated list of the property attibutes, setter is the name of the property setter method, provided the property is writable and property is the `Property` object. For read-only properties, the setter is an empty name `""`. Note: ObjC Property Attributes: T<type>"name" = Type & = Retain last value (retain) C = Copy D = Dynamic (@dynamic) G<name> = Getter selector name N = Non-atomic (nonatomic) P = To be garbage collected R = Read-only (readonly) S<name> = Setter selector name t<encoding> = Old-style type encoding W = Weak reference (__weak) See Also: Property Attributes.

### get_protocol(name) |
Get a registered ObjC protocol by name. Parameters: `name` - The protocol name (`str`). Returns: The protocol (Protocol_t) if found, `None` otherwise.

### get_protocols(clas, *prefixes) |
Yield all protocols of an ObjC class with a name starting with one of the given prefixes. Parameters: `clas` - The class (Class_t). `prefixes` - No, one or more protocol names to match (`str`-s). Returns: For each protocol, yield a 2-tuple (name, protocol) where name is the protocol name and protocol the Protocol_t object.

### get_resolutions(*printers) |
Yield the resolutions supported by the given printer(s). Parameters: `printers` - No, one or more printers (Printers). Returns: A 2-tuple (horizontal, vertical) in dots per inch (`float`s) for each resolution.

### get_selector(name_) |
Get an ObjC selector by name. Parameters: `name_` - The selector name (`str`). Returns: The selector (SEL_t) if found, `None` otherwise.

### get_selectorname_permutations(name_, leading=False) |
Yield all permutations of a Python-style selector name. Parameters: `name_` - The selector name with underscores (`str`). `leading` - In-/exclude leading underscores in name_ permutations (`bool`), default `False` meaning exclude. Returns: The selector name (`str`) for each underscore and colon permutation. Note: Only the underscores in name_ are permuted, any colons in name_ remain unchanged.

### get_selectornameof(sel) |
Get the name of an ObjC selector. Parameters: `sel` - The selector (SEL_t). Returns: The selector name (`str`) if found, `""` otherwise.

### get_superclass(clas) |
Get the ObjC super-class of an ObjC class. Parameters: `clas` - The class (Class_t). Returns: The super-class (Class_t), `None` otherwise.

### get_superclassnameof(objc, dflt=missing) |
Get the name of the ObjC super-class of an object. Parameters: `objc` - The object (`Object` or Id_t). Returns: The object'ssuper-class name (`str`). Raises: `ValueError` - Invalid objc, iff no dflt provided.

### get_superclassof(objc) |
Get the ObjC super-class of an object. Parameters: `objc` - The object (`Object` or Id_t). Returns: The super-class (Class_t), `None` otherwise.

### inst2strepr(inst, strepr, *attrs) |
Convert an instance's attributes, maintaining the order. Parameters: `inst` - Instance (`any`, incl. `ctypes`). `strepr` - Conversion (`repr` or `str`). `attrs` - Instance attribute names (all positional). Returns: Instance representation (`str`).

### int2NS(py, NS=None) |
Create an `NSNumber` from a Python `int` or `long`. Parameters: `py` - The value (`int` or `long`). `NS` - Alternate `NSNumber` ObjC class to use when py exceeds the `NSLong` or `NSLongLong` range, for example `NS=NSDecimal`. Returns: The ObjC instance (`NSNumber` or `NS` alternate). Raises: `TypeError` - If py not an `int` or `long`. `ValueError` - If py exceeds `NSLong` range and if no `NS` alternate is specified.

### isAlias(path) |
Resolve a macOS file or folder alias. Parameters: `path` - The alias name (`str` or NSStr). Returns: The alias' target (`str`) or `None` if path isn't a macOS alias. Raises: `TypeError` - Invalid path. See Also: mac-alias and here.

### isClass(objc) |
Check whether an object is an ObjC clas. Parameters: `objc` - Object to check (`Object` or `Class`). Returns: True if the objc is a clas, False otherwise.

### isImmutable(objc, *immutableClasses, **raiser_name) |
Check that an ObjC object is an immutable class' instance. Parameters: `objc` - The instance to check (ObjCInstance). `immutableClasses` - Optional immutable classes to use (`NS...` or `Object`s), in lieu of all predefined ones. `raiser_name` - Optional instance name (`str`) to raise TypeError. Returns: `True` if objc is immutable, `False` otherwise. Raises: `TypeError` - If objc isn't immutable, but only if keyword raiser='...' is specified.

### isLink(path) |
Resolve a file or folder link or alias. Parameters: `path` - The link or alias name (`str` or NSStr). Returns: The link's or alias' target (`str`) or `None` if path isn't a link or alias. Raises: `TypeError` - Invalid path.

### isMetaClass(objc) |
Check whether an object is an ObjC metaclass. Parameters: `objc` - Object to check (`Object` or `Class`). Returns: True if the objc is a metaclass, False otherwise.

### isMutable(objc, *mutableClasses, **raiser_name) |
Check that an ObjC object is a mutable class' instance. Parameters: `objc` - The instance to check (ObjCInstance). `mutableClasses` - Optional mutable classes to use (`NSMutable...`s or `Object`s), in lieu of all predefined ones. `raiser_name` - Optional instance name (`str`) to raise TypeError. Returns: `True` if objc is mutable, `False` otherwise. Raises: `TypeError` - If objc isn't mutable, but only if keyword raiser='...' is specified.

### isNone(obj) |
Return True if obj is `None, NSMain.nil, NSMain.Null`, etc. Parameters: `obj` - The object (ObjCInstance). Returns: True or False (`bool`).

### isObjCInstanceOf(objc, *Classes, **raiser_name) |
Check whether an ObjC object is an instance of some ObjC class. Parameters: `objc` - The instance to check (ObjCInstance or `c_void_p`). `Classes` - One or several ObjC classes (`Object`). `raiser_name` - Optional instance name (`str`) to raise TypeError. Returns: The matching Class from Classes, `None` otherwise. Raises: `TypeError` - If objc is not an ObjCInstance or `c_void_p` or if objc isn't any Classes' instance and only if keyword raiser='...' is specified. See Also: Function isinstanceOf for checking Python instances.

### is_enabled(sig=None) |
Check whether `fault` handling is enabled, similar to the faulthandler module available in Python 3.3 and later. Parameters: `sig` - Check whether `fault` handling includes this signal (`signal.SIG*`). Returns: `True` if `fault` handling is currently enabled, `False` otherwise.

### isinstanceOf(inst, *classes, **raiser_name) |
Check a Python instance' class. Parameters: `inst` - The instance to check (`any`). `classes` - One or several classes (all positional). `raiser_name` - Optional instance name (`str`) to raise `TypeError`. Returns: The `type{inst} if `isinstance(inst, classes`` else `None`. Raises: `TypeError` - If inst does not match any of the classes but only if keyword `raiser` is specified. See Also: Function isObjCInstanceOf for checking ObjC instances.

### islistuple(inst) |
Is `inst`ance a `list` or `tuple`? Parameters: `inst` - The object (any `type`). Returns: `True` if `inst` is a `list` or `tuple`, `False` otherwise.

### iterable2NS(py, frozen=True) |
Create an `NS[Mutable]Array` from a Python `iterable`. Parameters: `py` - The value (`iterable`). `frozen` - If `True`, return an immutable `NSArray`, otherwise an `NSMutableArray` (`bool`). Returns: The ObjC instance (`NSMutableArray` or immutable `NSArray`). Raises: `TypeError` - If py is not `iterable`.

### leaked2() |
Return the number of memory leaks. Returns: 2-Tuple (number, size) with the number of memory leaks and total size leaked, in bytes.

### list2NS(py) |
Create an `NSMutableArray` from a Python `list` or `tuple`. Returns: The ObjC instance (`NSMutableArray`). See Also: Function listuple2NS for further details.

### listuple2NS(py) |
Create an `NS[Mutable]Array` from a Python `list` or `tuple`. Parameters: `py` - The value (`list` or `tuple`). Returns: The ObjC instance (`NSMutableArray` or immutable `NSArray`). Raises: `RuntimeError` - If `len` vs `count` assertion failed. See Also: Functions list2NS and tuple2NS.

### macOSver() |
Return the macOS release as `str`. Note: `macOS 11 Big Sur` is `'10.16'` before Python 3.9.6 and on Apple Si Intel-emulation, see function machine.

### macOSver2(n=2) |
Return the macOS release as 1-, 2- or 3-tuple of `int`s. Note: `macOS 11 Big Sur` is `(10, 16)` before Python 3.9.6 and on Apple Si Intel-emulation, see function machine.

### machine() |
Return the `platform.machine` string, distinguishing Intel from emulating Intel on Apple Silicon (on macOS). Returns: Machine `'arm64'` for Apple Silicon, `"arm64_x86_64"` for Intel emulated, `'x86_64'` for Intel, etc. (`str` with any `comma`s replaced by `underscore`).

### map2NS(py, frozen=True) |
Create an `NS[Mutable]Array` from a Python `map`. Parameters: `py` - The value (`map`). `frozen` - If `True`, return an immutable `NSArray`, otherwise an `NSMutableArray` (`bool`). Returns: The ObjC instance (`NSArray` or `NSMutableArray`).

### name2objc(name_) |
Convert a (selector) name to `bytes` and ObjC naming rules. Parameters: `name_` - Name to convert (`str` or `bytes`). Returns: Converted name (`bytes`). Note: A name_ starting with an underscore is returned as-is.

### name2py(name_) |
Convert a (selector) name `str` and Python naming conventions. Parameters: `name_` - Name to convert (`str` or `bytes`). Returns: Converted name (`str`). Note: A name_ starting with an underscore is returned as-is.

### name2pymethod(name_) |
Convert a (selector) name to a valid Python callback method. Parameters: `name_` - Name to convert (`str` or `bytes`). Returns: Converted name (`str`). Raises: `ValueError` - Invalid, non-alphanumeric name_.

### ns2App(ns) |
Get the App instance from an `NSApplication` or an `NSNotification` instance. Parameters: `ns` - The ObjC instance (`NS...`). Returns: The app instance (App). Raises: `RuntimeError` - App mismatch. `TypeError` - Invalid ns type.

### ns2Item(ns) |
Get the Python instance for an `NSMenuItem`. Parameters: `ns` - The ObjC instance (`NSMenuItem`). Returns: The instance (Item or Menu). Raises: `TypeError` - Invalid ns type. Note: A Menu instance is returned if ns was an intermediate `NSMenuItem`, created internally to append or insert a Menu to a MenuBar.

### ns2NSType2(ns) |
Get the main `NS[Mutable]...` class and Python Type. Parameters: `ns` - The `NS...` instance (ObjCInstance). Returns: 2-Tuple `(NS, Type)` with the `NS[Mutable]...` class and Python Type, either may be `None`. Raises: `TypeError` - Invalid ns. See Also: Functions ns2Type and ns2TypeID2.

### ns2Type(ns) |
Convert an `NS...` ObjC object to an instance of the corresponding Python Type, capital T!. Parameters: `ns` - The `NS...` instance (ObjCInstance). Returns: The instance (`Python Type`).

### ns2TypeID2(ns, dflt=None) |
Get the `NS...` ObjC `TypeID`. Parameters: `ns` - The `NS...` instance (ObjCInstance). `dflt` - Default for unhandled, unexpected `NS...`s (`missing`). Returns: 2-Tuple `(TypeID, ns...2py)` of an `int`NS and the type conversion `callable`. Raises: `TypeError` - Invalid ns.

### ns2Window(ns) |
Get the Window instance for an ObjC `NSWindow` or `NSNotification` instance. Parameters: `ns` - The ObjC instance (`NS...`). Returns: The window instance (Window). Raises: `AttributeError` - Unexpected ns type. `RuntimeError` - Window mismatch. `TypeError` - Invalid ns type.

### ns2py(ns, dflt=missing) |
Convert an ObjC class' instance to the equivalent Python standard type's instance or wrapper and value. Parameters: `ns` - The `NS...` instance (ObjCInstance). `dflt` - Default for unhandled, unexpected `NS...`s (`missing`). Returns: The value (`Python type`) or dflt if provided. Raises: `TypeError` - Invalid ns or unhandled `TypeID`. Note: Conversion map: NSArray -> tuple NSBoolean -> bool NSConstantString -> str NSData -> bytes NSDecimalNumber -> Decimal NSDictionary -> frozendict NSMutableArray -> list NSMutableDictionary -> dict NSMutableSet -> set NSMutableString -> str NSNumber -> int or float NSNull -> None NSSet -> frozenset NSStr -> str NSString -> str See Also: Converting values between Python and Objective-C

### nsArray2listuple(ns, ctype=<class 'ctypes.c_void_p'>, typy=None) |
Create a Python `list` or `tuple` from an `NS[Mutable]Array`. Parameters: `ns` - The `NS[Mutable]Array` instance (ObjCInstance). `ctype` - The array item type (`ctypes`). `typy` - Use `typy=list`, `typy=tuple` or `typy=any_callable` to override the Python type. Returns: The array (`list` or `tuple` or `typy`). Raises: `TypeError` - Invalid ns.

### nsArray2tuple(ns, ctype=<class 'pycocoa.runtime.ObjCInstance'>, typy=<type 'tuple'>) |
Create a Python `tuple` from an immutable `NSArray`. Parameters: `ns` - The `NSArray` instance (ObjCInstance). `ctype` - The array item type (`ObjCInstance`). `typy` - Use `typy=any_callable` to override the Python `tuple` type. Returns: The array (`tuple` or `typy`). Raises: `TypeError` - Invalid ns.

### nsBoolean2bool(ns, dflt=missing) |
Create a Python `bool` from an `NSBoolean`. Parameters: `ns` - The `NSBoolean` instance (ObjCInstance). `dflt` - Default for a missing, unobtainable value (`missing`). Returns: The bool (`bool`) of dlft. Raises: `TypeError` - Invalid ns.

### nsBundleRename(ns_title, match=`'``Python``'`) |
Change the bundle title if the current title matches. Parameters: `ns_title` - New bundle title (NSStr). `match` - Optional, previous title to match (`str`). Returns: The previous bundle title (`str`) or None. Raises: `TypeError` - Invalid ns. Note: Used to mimick `NSApplication.setTitle_(ns_title)`, the name of an App shown in the menu bar.

### nsData2bytes(ns, dflt=`'````'`) |
Create Python `bytes` from `NSData`. Parameters: `ns` - The `NSData` instance (ObjCInstance). `dflt` - Default for empty `NSData` (`bytes`). Returns: The bytes (`bytes`) or dflt. Raises: `TypeError` - Invalid ns.

### nsDecimal2decimal(ns) |
Create a Python `Decimal` from an `NSDecimal`. Parameters: `ns` - The `NSDecimal` instance (ObjCInstance). Returns: The decimal (`Decimal`). Raises: `TypeError` - If ns not `NSDecimal`.

### nsDescription2dict(ns, **defaults) |
Create an immutable `dict` object with key and attribute access to items by name. Parameters: `ns` - The `NS...` instance (ObjCInstance). `defaults` - Optional defaults items (Any kwds).

### nsDictionary2dict(ns, ctype_keys=<class 'ctypes.c_void_p'>, ctype_vals=<class 'ctypes.c_void_p'>, typy=None) |
Create a Python `dict` or `frozendict` from an `NS[Mutable|Frozen]Dictionary`. Parameters: `ns` - The `NSDictionary` instance (ObjCInstance). `ctype_keys` - The dictionary keys type (`ctypes`). `ctype_vals` - The dictionary values type (`ctypes`). `typy` - Use `typy=dict`, `typy=Adict`, `typy=frozendict` or `typy=any_callable` to override the Python type. Returns: The dict (Adict or `frozendict` or `typy`). Raises: `TypeError` - Invalid ns.

### nsDictionary2items(ns) |
Yield the `(key, value)` items from an `NSDictionary`. Parameters: `ns` - The `NSDictionary` instance (ObjCInstance). Returns: A 2-tuple `(key, value)` for each item, where each `key` and `value` is an ObjCInstance. Raises: `TypeError` - Invalid ns.

### nsException(name=None, reason=`'``not given``'`, **info) |
Create an `ObjC/NSException` instance. Parameters: `name` - Ignored (NSExceptionName). `reason` - The reason for the exception (`str`). `info` - Other, caller-defined information (`all keywords`). Returns: The exception (`ObjC/NSException`). See Also: nsRaise, nsThrow and NSExceptionError. Notes: Use NSExceptionError`(nsExc)` to wrap a Python exception around an `ObjC/NSException` instance and get access to the attributes of the latter. Raised and thrown `NSException`s can not be caught and result in fatal exiting.

### nsIter(ns, reverse=False, keys=False) |
Iterate over an `NS..` ObjC objects's keys, values or reverse values. Parameters: `ns` - The `NS..` instance to iterate over (ObjCInstance). `reverse` - If `True`, iterate in reverse otherwise forward order over `ns`' values (`bool`). `keys` - If `True`, iterate over `ns`' keys, provided `ns` is an `NS[Mutable]Dictionary` and ignoring `reverse`. Returns: Yield each object or key (`NS...`). Raises: `TypeError` - Invalid ns. Note: If `ns` is an `NS[Mutable]Dictionary` and `keys=False`, the values of `ns` are enumerated in forward or `reverse` order.

### nsIter2(ns, reverse=False, keys=False) |
Iterate over an `NS..` ObjC objects's keys or (reverse) values. Returns: Yield each object as 2-Tuple (py, ns) where py is a Python `Type` instance and ns the object `NS...`. Raises: `TypeError` - Invalid ns. See Also: Function nsIter for `ns`, `reverse` and `key` details and function ns2Type for Python `Type`s.

### nsLog(ns_fmt, *ns_args) |
Formatted ObjC write to the console. Parameters: `ns_fmt` - A printf-like format string (NSStr). `ns_args` - Optional arguments to format (`all positional`). Raises: `TypeError` - Invalid ns_fmt. Note: The ns_fmt and all ns_args must be `NS...` ObjC instances. See Also: Dglessus' nslog.py.

### nsLogf(fmtxt, *args) |
Formatted write to the console. Parameters: `fmtxt` - A printf-like format string (`str`). `args` - Optional arguments to format (`all positional`). Raises: `TypeError` - Invalid fmtxt. See Also: nsLog.

### nsNull2none(ns) |
Return Python `None` for an `NS/CFNull` or `nil`. Parameters: `ns` - The `NS...` instance (ObjCInstance). Returns: The singleton (`None`). Raises: `TypeError` - Invalid ns. `ValueError` - If ns not `isNone`.

### nsNumber2num(ns, dflt=missing) |
Create a Python `Decimal`, `int` or `float` from an `NSNumber`. Parameters: `ns` - The `NSNumber` instance (ObjCInstance). `dflt` - Default for missing, unobtainable value (`missing`). Returns: The number (`Decimal`, `int` or `float`). Raises: `TypeError` - Invalid ns. `ValueError` - If ns not an `NSNumber`.

### nsOf(inst) |
Return the `.NS` ObjC object of a Python wrapper or Type instance. Parameters: `inst` - The wrapper (ObjCInstance or `Python Type`). Returns: The `.NS` object (`NS...`). Raises: `TypeError` - No `.NS` for this inst.

### nsRaise(name=None, reason=`'``not given``'`, **info) |
Create an `NSException` and mimick `@throw NSException`. Parameters: `name` - Ignored (NSExceptionName). `reason` - The reason for the exception (`str`). `info` - Other, caller-defined information (`all keywords`). Note: Raised `NSException`s can not be caught and result in fatal exiting. See Also: NSException and nsThrow.

### nsSet2set(ns, ctype=<class 'ctypes.c_void_p'>, typy=None) |
Create a Python `set` or `frozenset` from an `NS[Mutable]Set`. Parameters: `ns` - The `NS[Mutable]Set` instance (ObjCInstance). `ctype` - The set item type (`ctypes`). `typy` - Use `typy=set`, `typy=frozenset` or `typy=any_callable` to override the Python type. Returns: The set (`set` or `frozenset` or `typy`). Raises: `TypeError` - Invalid ns.

### nsString2str(ns, dflt=None) |
Create a Python `str` or `unicode` from an `NS[Mutable]Str[ing]`. Parameters: `ns` - The `NS[Mutable]Str[ing]` instance (ObjCInstance). Returns: The string (`str` or `unicode`) or dflt.

### nsTextSize3(text, ns_font=None) |
Return the size of a multi-line text. Parameters: `text` - The text (`str`), including `linesep`arators. `ns_font` - The text font (`NSFont`) or `None`. Returns: 3-Tuple (width, height, lines) in (pixels, pixels) or in (characters, lines, lines) if ns_font is `None`.

### nsTextView(text, ns_font, scroll=50) |
Return an `NSTextView` for the given text string. Parameters: `scroll` - Make the `NSTextView` scrollable if the number of text lines exceeds `scroll` (`int`).

### nsThrow(nsExc) |
Mimick ObjC's `@throw NSException` to raise an exception. Parameters: `nsExc` - The exception to raise (`NSException`). Raises: `TypeError` - Invalid nsExc. See Also: NSException and nsRaise. Note: Thrown `NSException`s can not be caught and result in fatal exiting.

### nsURL2str(ns) |
Create a Python `str` from `NSURL` string. Parameters: `ns` - The `CFURL` instance (ObjCInstance). Returns: The URL as string (`str`). Raises: `TypeError` - Invalid ns.

### nsValue2py(ns, dflt=missing) |
Create a Python instance from an `NS[Concrete]Value`. Parameters: `ns` - The `NS[Concrete]Value` instance (ObjCInstance). `dflt` - Default for missing, unobtainable value. Returns: The value (`NSPoint_t`, `NSRange_t`, `NSRect_t`, `NSSize_t` or `tuple`) or dflt. Raises: `TypeError` - Invalid ns or unhandled `ns.objCType`. `TypeError` - Invalid ns.

### printf(fmtxt, *args, **file_flush_nl_nt_argv0) |
Formatted print fmt % args with optional keywords. Parameters: `fmtxt` - Print-like format or plain string (`str`). `args` - Optional arguments to format (all positional). `file` - Alternate file to write to (`file`-type), default `sys.stdout`. `flush` - Flush `file` after writing (`bool`), default `False`. `nl` - Number of leading blank lines (`int`). `nt` - Number of trailing blank lines (`int`, default 1). `argv0` - Optional prefix (`str`). Returns: Number of bytes written (`int`).

### properties(inst) |
All property names and values. Parameters: `inst` - An instance (`any`). Returns: The properties (`dict`).

### property_RO(method) |
Decorator for `Read_Only` class/instance property. Parameters: `method` - The callable to be decorated as `Read_Only property`. Note: Like standard Python `property` without a `property.setter` and with an error message when trying to set.

### py2NS(py) |
Convert (an instance of) a Python object into an instance of the equivalent `NS...` ObjC class: Parameters: `py` - The value (`Python type`). Returns: The ObjC instance (ObjCInstance). Raises: `TypeError` - Unhandled, unexpected `Python type`. Note: Conversion map: bool -> NSBoolean/NSNumber bytes -> NSData (Python 3+ only) bytearray -> NSData Decimal -> NSDecimal dict -> NSMutableDictionary float -> NSNumber frozendict -> NSDictionary, immutable frozenset -> NSSet, immutable generator -> NSArray, immutable (like tuple) int -> NSNumber list -> NSMutableArray map -> NSArray, immutable (like tuple, Python 3+ only) None -> NSNull range -> NSArray, immutable (like tuple) set -> NSMutableSet str -> NSStr, immutable tuple -> NSArray, immutable unicode -> NSStr, immutable See Also: Converting values between Python and Objective-C

### range2NS(py, frozen=True) |
Create an `NS[Mutable]Array` from a Python `range`. Parameters: `py` - The value (`range`). `frozen` - If `True`, return an immutable `NSArray`, otherwise an `NSMutableArray` (`bool`). Returns: The ObjC instance (`NSMutableArray` or immutable `NSArray`).

### register_subclass(subclas) |
Register an ObjC sub-class. Parameters: `subclas` - Class to be registered (`Class`). See Also: ObjCSubclass`.register`.

### release(objc) |
Release an ObjC instance to be deleted, eventually. Parameters: `objc` - The instance to release (ObjCInstance). Returns: The instance objc. Raises: `TypeError` - If objc is not releasable. Note: May result in Python memory errors, aborts and/or segfaults. Use 'python3 -X faulthandler ...' to get a Python traceback in such circumstances.

### retain(objc) |
Preserve an ObjC instance from destruction. Parameters: `objc` - The instance to retain (ObjCInstance). Returns: The retained instance objc. Raises: `TypeError` - If objc is not retainable. Note: May result in Python memory errors, aborts and/or segfaults. Use 'python3 -X faulthandler ...' to get a Python traceback in such circumstances.

### segfaulty() |
Return `True` if SegfaultErrors are raised to prevent certain SEGFAULTs, `False` if SEGFAULTs are not expected or `None` if unknown. Note: Functions `pycocoa.get_classes`, `pycocoa.get_classname`, `pycocoa.get_classnameof` and `pycocoa.get_classof` may SEGFAULT or hang infinitely since macOS 15.0 Sequoia on Intel (`x86_64`) and Intel emulation (`"arm64_x86_64"`. By default `pycocoa` raises a `SegfaultError` in that case unless `fault handling` is enabled, see module pycocoa.faults. Set env variable `PYCOCOA_SEGFAULTY` to any non-empty string to suppress `SegfaultError` exceptions and to risk SEGFAULTs and hangs.

### send_message(objc, sel_name_, *args, **restype_argtypes) |
Send message to an ObjC object. Parameters: `objc` - The recipient (`Object`, `Id_t`, etc.) instance. `sel_name_` - Message selector (`SEL_t`) or name (`str` or `bytes`). `args` - Message arguments (all positional). `resargtypes` - Optional, result and argument types (`ctypes`). Returns: Message result (restype). Raises: `ArgumentError` - Invalid objc, sel_name_, args or resargtypes. `TypeError` - Invalid objc, sel_name_, args or resargtypes type. Note: By default, the result and any arguments are `c_void_p` wrapped. Use keyword arguments restype=c_void_p and argtypes=[] to change the defaults. The restype defines the `ctypes` type for the returned result and argtypes is the list of `ctypes` types for the message arguments only without the `Id/self` and `SEL/cmd` arguments.

### send_super(objc, sel_name_, *args, **restype_argtypes) |
Send message to the super-class of an ObjC object. Parameters: `objc` - The recipient (`Object`, `Id_t`, etc.) instance. `sel_name_` - Message selector (`SEL_t`) or name (`str` or `bytes`). `args` - Message arguments (all positional). `resargtypes` - Optional, result and argument types (`ctypes`). Returns: Message result (restype). Raises: `ArgumentError` - Invalid objc, sel_name_, args or resargtypes. `TypeError` - Invalid objc, sel_name_, args or resargtypes type. Note: By default, the result and any arguments are `c_void_p` wrapped. Use keyword arguments restype=c_void_p and argtypes=[] to change the defaults. The restype defines the `ctypes` type for the returned result and argtypes is the list of `ctypes` types for the message arguments only without the `Id/self` and `SEL/cmd` arguments.

### send_super_init(objc) |
Send 'init' message to the super-class of an ObjC object. Parameters: `objc` - The recipient (`Object`, `Id_t`, etc.) instance. Returns: Message result (`Id_t`).

### set2NS(py) |
Create an `NSMutableSet` from a Python `set` or `frozenset`. Returns: The ObjC instance (`NSMutableSet`). See Also: Function sets2NS for further details.

### setUncaughtExceptionHandler(handler, log=True, raiser=False) |
Install a callback to handle uncaught `ObjC/NSException`s. The `handler(error)` is called with one argument `error`, an NSExceptionError instance. It should return that same `error`, an exiting `status` or `None`. In in former case, that `error` will subsequently be raised as Python exception. Parameters: `handler` - A callable to be invoked with a single argument `error`, an NSExceptionError instance and to return that same `error`, an exiting `status` or `None`. `log` - Print the `error`, an time stamp and -if avilable- the ObjC callstack and Python traceback prior to invoking the `handler` (`bool`). `raiser` - Raise the NSExceptionError `error`, regardless of the return value from the `handler`. Returns: The previously installed uncaught `ObjC/NSException` handler or `None` if no handler was or couldn't be installed. Raises: `RuntimeError` - Setting uncaught exception handlers unavailable, but only thrown if `raiser`=True. `TypeError` - The `handler` is not callable. Notes: Faults like `SIGILL`, `SIGSEGV`, etc. do not throw uncaught `ObjC/NSException`s and will not invoke the given `handler`. However, those and several other signals can be handled as `fault`s, see faults.enable, faults.disable and other functions module faults. An uncaught `ObjC/NSException` always results in (graceful) termination of the process. Uncaught `ObjC/NSException`s are not reported to an `NSLog` file (yet). See Also: Dgelessus' pythonista_startup.py, Handling Exceptions and Error Handling Programming Guide.

### set_ivar(objc, name, value, ctype=None) |
Set an instance variable of an ObjC object. Parameters: `objc` - The instance (`Object`). `name` - Name of the ivar (`str`). `value` - New value for the ivar (`any`). `ctype` - Optional, the ivar type (`ctypes`). Returns: The ivar (Ivar_t). Raises: `ArgumentError` - Invalid name, value or ctype. `TypeError` - Invalid name, value or ctype type.

### sets2NS(py) |
Create an `NS[Mutable]Set` instance from a Python `set` or `frozenset`. Parameters: `py` - The value (`set` or `frozenset`). Returns: The ObjC instance (`NSMutableSet` or immutable `NSSet`). Raises: `RuntimeError` - If `len` vs `count` assertion failed. `TypeError` - If py is not `set` nor `frozenset`.

### split_emcoding2(encoding, start=0) |
Split the type encoding of a method signature into separate, single encodings and the combined encoding. If necessary, the encoding is extended with the type encoding for the hidden method arguments `Id/self` and `SEL/cmd`. Returns: 2-Tuple (codes, encoding), where codes is the list of individual type encodings from item start=0 and encoding is the combined type encoding in `bytes`, both extended with `Id/self` and `SEL/cmd` iff needed. Raises: `TypeCodeError` - Invalid or unbalanced encoding. Note: Does not handle `bitfield`s, `array`s, `struct`s, `union`s, etc. and strips any offset, size or width specifiers from the encoding. Example:
    >>> split_emcoding2('v*')
    >>> (['v', '@', ':', '*'], 'v@:*')

### split_encoding(encoding) |
Split a type encoding into separate type encodings. Does not handle `bitfield`s, `array`s, `struct`s, `union`s, etc. and strips any offset, size or width specifiers from the encoding. Returns: The individual type encodings (`list`). Raises: `TypeCodeError` - Invalid or unbalanced encoding. Example:
    >>> split_encoding('^v16@0:8')
    >>> ['^v', '@', ':']
    >>> split_encoding('{CGSize=dd}40@0:8{PyObject=@}Q32')
    >>> ['{CGSize=dd}', '@', ':', '{PyObject=@}', 'Q']
Supported Type Encodings: B = bool (C++ bool, C99 _Bool) c, C = char, unsigned char f, d = float, double i, I = int, unsigned int l, L = long, unsigned long (32-bit in 64-bit Apps) q, Q = long long, unsigned long long s, S = short, unsigned short t, T = 128-bit int, unsigned int v = void * = string (char *) : = method selector `SEL/cmd` # = class #"name" = class "name" @ = object instance `Id/self` or statically typed @"name" = instance `Id/self` of class "name" ^type = pointer to type ? = unknown type (among other things, used for function pointers) PyCocoa specific: P = Python object, shorthand for `PyObjectEncoding` Unsupported Type Encodings: bW = bitfield of width W [Ltype] = array of L items of type {name=type...} = structure (name=type...) = union <...> = block ?<...> = block with signature Unknown or for ObjC internal use: A = ? j = ? n, N = in, inout o, O = out, bycopy r, R = const, byref V = oneway Note: Type encodings may be preceeded by `"name"`, for example a `bitfield` `"name"b1`, `struct` items `{CGsize="width"d"heigth"d}`, `union` items, etc. and all such `"name"` prefixes are ignored. See Also: Type Encodings, NSHipster Type Encodings and Digits in type encoding.

### str2NS(py) |
Create an `NSStr` instance from a Python `str`. Parameters: `py` - The value (`str`). Returns: The ObjC instance (`NSStr`). See Also: Function strs2NS.

### str2bytes(strbytes, dflt=missing, **name) |
Convert `strbytes` to `bytes`/`unicode` if needed. Parameters: `strbytes` - Original `str`, `bytes` or `unicode`. `dflt` - Optional, default return value. `name` - Optional name of bytestr argument. Returns: The `bytes` or dflt. Raises: `TypeError` - If neither `bytes` nor `str`, but only if no dflt is specified.

### strs2NS(py, frozen=True) |
Create an `NS[Mutable]String` from a Python `str`. Parameters: `py` - The value (`str`). `frozen` - If `True`, return an immutable `NSString`, otherwise an `NSMutableString` (`bool`). Returns: The ObjC instance (`NSMutableString` or immutable `NSString`). See Also: Function str2NS.

### terminating(app, timeout=None) |
Set up a separate thread to terminate an NSApplication app by calling its `.terminate_` method at the given timeout in seconds. Returns: Timeout in seconds (`float`) or `None`. Note: Similarly, the NSWindow could be closed, provided the NSWindow or NSApplication `Delegate` instance includes the `.windowWillClose_` method which in turn invokes the NSApplication's `.terminate_` method.

### time2NS(py=None, since=1970) |
Create an `NSDate` instance from a timestamp. Parameters: `py` - The timestamp in seconds (`float`, `int`). `since` - Epoch start (1970, 2001) otherwise now. Returns: The ObjC instance (`NSDate`). Note: Using `py=None` means `py=0, since=None` or `py=time.time(), since=1970`.

### title2action(title) |
Convert a menu item `title` to a Python callback method name. Parameters: `title` - The item's title (`str`). Returns: Name for the Python callback method (`str`), the title with all non-alphanumeric characters except colon and underscore removed, with prefixed `"menu"` and suffix `"_"` added. Raises: `ValueError` - If title can not be converted.

### tuple2NS(py) |
Create an immutable `NSArray` instance from a Python `tuple` or `list`. Returns: The ObjC instance (`NSArray`, immutable). See Also: Function listuple2NS for further details.

### type2NS(py) |
Create the `NS...` ObjC object for a Python Type (or wrapper) instance. Parameters: `py` - The value (`Type`). Returns: The ObjC instance (ObjCInstance). Raises: `TypeError` - Unhandled, unexpected `Type`. See Also: Function py2NS.

### type2strepr(inst, strepr=<type 'str'>, **kwds) |
Represent a Python Type instance as `str` or `repr`. Parameters: `inst` - Instance (`any`). `strepr` - Representation function (`repr` or `str`). `kwds` - Optional, additional `name=value` arguments. Returns: Instance representation (`str`).

### unicode2NS(py) |
Create an `NSStr` instance from a Python `unicode` string. Parameters: `py` - The value (`unicode`). Returns: The ObjC instance (`NSStr`).

### url2NS(py, url2=None) |
Create an `NSURL` instance from a Python string. Parameters: `py` - The URL (`str` or `unicode`). `url2` - Optionally, relative to this URL (`str` or `unicode`). Returns: The ObjC instance (`NSURL`). See Also: URL for parsing an `NSURL`.

### windowStyles(*styles) |
Return a combination of window styles, specified by name. Parameters: `styles` - Style names (all positional), case-insensitive. Returns: Combined styles (WindowStyles `mask`). Raises: `WindowStyleError` - One or more styles are invalid.

### z1000str(size, sep='_') |
Convert a size to string with 1_000's seperator. Parameters: `size` - Value to convert (`float` or `int`). `sep` - 1_000's separator (`str`). Returns: "<1or2digits><sep><3digits>..." or "-" if size is negative (`str`).

### zSIstr(size, B=`'``B``'`, K=1024) |
Convert a size to string with SI-units suffix. Parameters: `size` - Value to convert (`float` or `int`). `B` - The unit (`str`). `K` - 1024 or 1000 (`int`). Returns: "<Size> <SI>[i]<B>" (`str`).

### zfstr(flt, prec=3) |
Format a `float` and strip trailing zero decimals. Parameters: `flt` - Value (`float`). `prec` - Number of decimals (`int`). Returns: Value (`str`).

Variables Details

  ### pycocoa_abspath Value:
      '..../PyCocoa/pycocoa'

  ### AlertStyle Value:
      AlertStyle.Critical=2,
                .Info=1,
                .Informational=1,
                .Warning=0

  ### AutoResize Value:
      AutoResize.HeightSizable=16 or 1<<4,
                .MaxXMargin=4 or 1<<2,
                .MaxYMargin=32 or 1<<5,
                .MinXMargin=1,
                .MinYMargin=8 or 1<<3,
                .NotSizable=0,
                .Sizable=18,
                .WidthSizable=2

  ### BezelStyle Value:
      BezelStyle.Circular=7,
                .Disclosure=5,
                .HelpButton=9,
                .Inline=15,
                .Recessed=13,
                .RegularSquare=2,
                .Rounded=1,
                .RoundedDisclosure=14,
      ...

  ### Border Value:
      Border.Bezel=2,
            .Groove=3,
            .Line=1,
            .No=0

  ### CMYColors Value:
      CMYColors.Cyan=CMYColor(_NSTaggedPointerColor, name='Cyan'),
               .Magenta=CMYColor(_NSTaggedPointerColor, name='Magenta'),
               .Yellow=CMYColor(_NSTaggedPointerColor, name='Yellow')

  ### Colors Value:
      Colors.CMY=CMYColors,
            .GS=GrayScaleColors,
            .HSB=HSBColors,
            .RGB=RGBColors,
            .Tint=TintColors,
            .UI=UIColors

  ### FontDesign Value:
      FontDesign.Default=0,
                .MonoSpaced=1,
                .Rounded=2,
                .Serif=3

  ### FontTextStyle Value:
      FontTextStyle.Body=11,
                   .Callout=31,
                   .Caption=21,
                   .Caption2=22,
                   .Footnote=41,
                   .Headline=51,
                   .HeadlineSub=50,
                   .SubHeadline=50,
      ...

  ### FontTrait Value:
      FontTrait.Bold=2,
               .Compressed=512 or 1<<9,
               .Condensed=64 or 1<<6,
               .Expanded=32 or 1<<5,
               .Italic=1,
               .MonoSpace=1024 or 1<<10,
               .Narrow=16 or 1<<4,
               .Poster=256 or 1<<8,
      ...

  ### FontWeight Value:
      FontWeight.Black=12 or 3<<2,
                .Bold=9,
                .BoldSemi=8 or 1<<3,
                .Hairline=1,
                .Heavy=15,
                .Light=1,
                .Medium=7,
                .Normal=5,
      ...

  ### Fonts Value:
      Fonts.App=Font.Helvetica(family=Helvetica, size=12, weight=5),
           .Bold=Font..AppleSystemUIFontBold(family=.AppleSystemUIFont, size
      =13, traits='Bold', weight=9),
           .BoldItalic=Font..AppleSystemUIFontEmphasizedItalic(family=.Apple
      SystemUIFont, size=13, traits='Italic Bold', weight=9),
           .Italic=Font..AppleSystemUIFontItalic(family=.AppleSystemUIFont,
      size=13, traits='Italic', weight=5),
           .Label=Font..AppleSystemUIFont(family=.AppleSystemUIFont, size=10
      ...

  ### GrayScaleColors Value:
      GrayScaleColors.Black=GrayScaleColor(_NSTaggedPointerColor, name='Blac
      k'),
                     .Clear=GrayScaleColor(_NSTaggedPointerColor, name='Clea
      r'),
                     .DarkGray=GrayScaleColor(_NSTaggedPointerColor, name='D
      arkGray'),
                     .Gray=GrayScaleColor(_NSTaggedPointerColor, name='Gray'
      ),
      ...

  ### Keys Value:
      Keys.ACK=0x6,
          .Acknowledge=0x6,
          .BackSpace=0x8,
          .BackTab=0x19,
          .BEL=0x7,
          .Bell=0x7,
          .BS=0x8,
          .BT=0x19,
      ...

  ### Libs Value:
      {'CoreFoundation': <CDLL 'CoreFoundation.framework/CoreFoundation', ha
      ndle 7fffa23e03a0 at 7f81385a5590>, 'Foundation': <CDLL 'Foundation.fr
      amework/Foundation', handle 7fffa23ef9a8 at 7f8138442390>, 'C': <CDLL
      'libc.dylib', handle 7fffa23d9ce0 at 7f81385a52d0>, 'Quartz': <CDLL 'C
      oreGraphics.framework/CoreGraphics', handle 7fffa23ea520 at 7f81385a5f
      10>, 'libc': <CDLL 'libc.dylib', handle 7fffa23d9ce0 at 7f81385a52d0>,
       'ObjC': <CDLL 'libobjc.dylib', handle 7fffa23e3c6c at 7f8138442650>,
      'PrintCore': <CDLL '/System/Library/Frameworks/ApplicationServices.fra
      ...

  ### NSAlertDelegate Value:
      <pycocoa.internals.proxy_RO object at 0x7f81384b2290>

  ### NSApplicationDelegate Value:
      <pycocoa.internals.proxy_RO object at 0x7f8138412450>

  ### NSDefaultRunLoopMode Value:
      _dllattr(_libAppKit, NSDefaultRunLoopMode= RunLoop_t)

  ### NSEventTrackingRunLoopMode Value:
      _dllattr(_libAppKit, NSEventTrackingRunLoopMode= RunLoop_t)

  ### NSMain Value:
      NSMain.Application=NSApplication(<Id_t at 0x7f8118e90b90>) of 0x7f8133
      ff7890,
            .BooleanNO=NSBoolean(<Id_t at 0x7f8118e90830>) of 0x7ff85bd2f088
      ,
            .BooleanYES=NSBoolean(<Id_t at 0x7f8118e937a0>) of 0x7ff85bd2f07
      8,
            .Bundle=NSBundle(<Id_t at 0x7f8118e904d0>) of 0x600000d705a0,
            .BundleName=NSConstantString('CFBundleName'),
      ...

  ### NSTableViewDelegate Value:
      <pycocoa.internals.proxy_RO object at 0x7f81384e5550>

  ### NSWindowDelegate Value:
      <pycocoa.internals.proxy_RO object at 0x7f8138667210>

  ### OBJC_ASSOCIATION Value:
      OBJC_ASSOCIATION.ASSIGN=0,
                      .COPY=771,
                      .RETAIN=769

  ### PanelButton Value:
      PanelButton.Cancel=0,
                 .Close=1,
                 .Error=-3,
                 .OK=1,
                 .Other=2,
                 .Suppressed=-2,
                 .TimedOut=-1

  ### RGBColors Value:
      RGBColors.Blue=RGBColor(_NSTaggedPointerColor, name='Blue'),
               .Brown=RGBColor(_NSTaggedPointerColor, name='Brown'),
               .Green=RGBColor(_NSTaggedPointerColor, name='Green'),
               .Orange=RGBColor(NSCachedRGBColor, name='Orange'),
               .Purple=RGBColor(NSCachedRGBColor, name='Purple'),
               .Red=RGBColor(_NSTaggedPointerColor, name='Red')

  ### Screens Value:
      (Screen(NSScreen, name='BuiltIn'), Screen(NSScreen, name='External'))

  ### TintColors Value:
      TintColors.Blue=TintColor(NSDynamicSystemColor, name='Blue'),
                .Brown=TintColor(NSDynamicSystemColor, name='Brown'),
                .Gray=TintColor(NSDynamicSystemColor, name='Gray'),
                .Green=TintColor(NSDynamicSystemColor, name='Green'),
                .Indigo=TintColor(NSDynamicSystemColor, name='Indigo'),
                .Orange=TintColor(NSDynamicSystemColor, name='Orange'),
                .Pink=TintColor(NSDynamicSystemColor, name='Pink'),
                .Purple=TintColor(NSDynamicSystemColor, name='Purple'),
      ...

  ### UIColors Value:
      UIColors.Control=UIColor(NSDynamicSystemColor, name='Control'),
              .ControlBackground=UIColor(NSDynamicSystemColor, name='Control
      Background'),
              .Grid=UIColor(NSDynamicSystemColor, name='Grid'),
              .HeaderText=UIColor(NSDynamicSystemColor, name='HeaderText'),
              .Highlight=UIColor(NSDynamicSystemColor, name='Highlight'),
              .Label=UIColor(NSDynamicSystemColor, name='Label'),
              .Link=UIColor(NSDynamicSystemColor, name='Link'),
      ...

  ### WindowStyle Value:
      WindowStyle.Closable=2,
                 .Miniaturizable=4 or 1<<2,
                 .Resizable=8 or 1<<3,
                 .Titled=1,
                 .Typical=15,
                 .Utility=16 or 1<<4

  ### libAppKit Value:
      <CDLL 'AppKit.framework/AppKit', handle 7fffa23edf68 at 7f81385a5d50>

  ### libCF Value:
      <CDLL 'CoreFoundation.framework/CoreFoundation', handle 7fffa23e03a0 a
      t 7f81385a5590>

  ### libCG Value:
      <CDLL 'CoreGraphics.framework/CoreGraphics', handle 7fffa23ea520 at 7f
      81385a5f10>

  ### libCT Value:
      <CDLL 'CoreText.framework/CoreText', handle 7fffa23ee430 at 7f8138431e
      90>

  ### libFoundation Value:
      <CDLL 'Foundation.framework/Foundation', handle 7fffa23ef9a8 at 7f8138
      442390>

  ### libPC Value:
      <CDLL '/System/Library/Frameworks/ApplicationServices.framework/Framew
      orks/PrintCore.framework/PrintCore', handle 7fffa23cfd38 at 7f813864c2
      d0>

  ### libobjc Value:
      <CDLL 'libobjc.dylib', handle 7fffa23e3c6c at 7f8138442650>