def handleMenuItem_(self, ns_item): '''ObjC callback to handle and dispatch C{NSMenuItem} clicks and shortcuts. All clicks and shortcuts are dispatched to the I{action} method of this I{NSDelegate}'s L{App} instance. Unhandled clicks, shortcuts and dispatch errors are silently ignored, unless L{App} C{raiser} keyword argument was C{True}. ''' item = ns2Item(ns_item) act = item._action for t, i in ((self.app, item), (self, ns_item)): m = getattr(t, act, None) if m and callable(m): try: m(i) break except Exception: if _Globals.raiser: printf('%s(%r): %r method %s ...', _handleMenuItem_name, i, t, act) raise else: if _Globals.raiser: raise RuntimeError('%s(%r): %s' % ('unhandled', item, act))
def callMenuItem_(self, ns_item): '''ObjC callback to directly call the action for C{NSMenuItem} clicks and shortcuts. Unhandled clicks, shortcuts and dispatch errors are silently ignored, unless L{App} C{raiser} keyword argument was C{True}. ''' item = ns2Item(ns_item) act = item._action try: act(item) except Exception: if _Globals.raiser: printf('%s(%r): callable %r ...', _callMenuItem_name, item, act) raise
x += 1 self._screens = d self._len = x return self._screens Screens = Screens() # PYCHOK tuple-like, singleton _Types.Screen = NSScreen._Type = Screen if __name__ == '__main__': from pycocoa.utils import _all_listing, printf for s in tuple(Screens) + (Screens.Deepest, Screens.Main): printf(str(s), nl=1) for a in ('colorSpace', 'displayID', 'frame', 'named', 'pixels', 'ratio', 'resolutions', 'visibleFrame'): printf(' %s: %r', a, getattr(s, a, None)) _all_listing(__all__, locals()) # % python3 -m pycocoa.screens # # pycocoa BuiltInScreen(NSScreen, name='BuiltIn') # pycocoa colorSpace: 'NSCalibratedRGBColorSpace' # pycocoa displayID: 1 # pycocoa frame: Rect(origin=Point(x=0.0, y=0.0), size=Size(width=1440.0, height=900.0)) at 0x101332a90 # pycocoa named: 'Built-in Retina Display' # pycocoa pixels: Size(width=2560.0, height=1600.0) at 0x101332dc0 # pycocoa ratio: (8, 5)
# End of list # kPMLastErrorCodeToMakeMaintenanceOfThisListEasier = -9799 _Types.Paper = Paper _Types.PaperCustom = PaperCustom _Types.PaperMargins = PaperMargins _Types.Printer = Printer if __name__ == '__main__': from pycocoa.utils import _all_listing, _Globals, printf _Globals.argv0 = _NN_ for i, p in enumerate(get_printers()): printf('%2s %s: ID %r, makemodel %r, URI %r', i + 1, p, p.ID, p.makemodel, p.deviceURI) d = get_printer() if d: printf('default (%s) printer: %s...', d.isDefault, d, nl=1) for a in ('name', 'ID', 'makemodel', 'isColor', 'location', 'psCapable', 'psLevel', 'isRemote', 'deviceURI', 'deviceDescription', 'description', 'PPD', 'resolution'): printf(' %s: %r', _DOT_(d, a), getattr(d, a)) printf(_NN_) for i, p in enumerate(get_papers(d)): t = tuple(map(zfstr, (p.width, p.height) + p.size2inch)) printf('%2s %s: ID %r, %sx%s (%sX%s)', i + 1, p, p.ID, *t) p = Paper('A4')
if __name__ == '__main__': from pycocoa.utils import _all_exports, _all_listing, \ bytes2repr, _Globals, printf _all_exports(locals(), 'PyObjectEncoding', 'TypeCodeError', 'c_void', starts=('CG', 'CF', 'NS', 'ObjC', 'is', 'split_'), ends='_t') _Globals.argv0 = '' def _c(ctype): return 'c_void' if ctype is c_void else ctype.__name__ printf('%s ...', 'ctype2encoding', nl=1) i = 0 for c, e in sorted((_c(c), e) for c, e in _ctype2encoding.items()): i += 1 printf('%4s: %-9s -> %s', i, c, bytes2repr(e)) printf('%s ...', 'encoding2ctype', nl=1) e = _encoding2ctype.copy() e.update(_emcoding2ctype) i = 0 for e, c in sorted(e.items()): i += 1 printf('%4s: %-5s -> %s', i, bytes2repr(e), _c(c)) printf('%s ...', 'checking NS...Encoding', nl=1) for t, e in ((NSPoint_t, NSPointEncoding),