本文整理汇总了Python中objc.lookUpClass方法的典型用法代码示例。如果您正苦于以下问题:Python objc.lookUpClass方法的具体用法?Python objc.lookUpClass怎么用?Python objc.lookUpClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类objc
的用法示例。
在下文中一共展示了objc.lookUpClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup
# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def _setup():
NSDictionary = _objc.lookUpClass("NSDictionary")
NSMutableDictionary = _objc.lookUpClass("NSMutableDictionary")
def CFDictionaryCreate(
allocator, keys, values, numValues, keyCallbacks, valueCallbacks
):
assert keyCallbacks is None
assert valueCallbacks is None
keys = list(keys)[:numValues]
values = list(values)[:numValues]
return NSDictionary.dictionaryWithDictionary_(dict(zip(keys, values)))
def CFDictionaryCreateMutable(allocator, capacity, keyCallbacks, valueCallbacks):
assert keyCallbacks is None
assert valueCallbacks is None
return NSMutableDictionary.dictionary()
return CFDictionaryCreate, CFDictionaryCreateMutable
示例2: ClassNameIncrementer
# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def ClassNameIncrementer(clsName, bases, dct):
orgName = clsName
counter = 0
while True:
try:
objc.lookUpClass(clsName)
except objc.nosuchclass_error:
break
counter += 1
clsName = orgName + str(counter)
return type(clsName, bases, dct)
示例3: setG
# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def setG(self, layer):
if layer.isKindOfClass_(objc.lookUpClass("GSControlLayer")):
return
self.output = '\\' + layer.parent.name + '\\\n' + self.output
self.layerID = layer.associatedMasterId
self.master = self.font.masters[self.layerID]
self.glyph = layer.parent
self.layer = layer
self.category = layer.parent.category
self.subCategory = layer.parent.subCategory
self.script = layer.parent.script
self.engine.reference = self.glyph.name
exception = self.findException()
if (exception):
self.engine.factor = exception[3]
item = exception[4]
if item != '*':
self.engine.reference = item
self.engine.newWidth = False
# check reference layer existance and contours
if self.font.glyphs[self.engine.reference]:
self.referenceLayer = self.font.glyphs[self.engine.reference].layers[self.layerID]
if len(self.referenceLayer.paths) < 1:
self.output += "WARNING: The reference glyph declared (" + self.engine.reference + ") doesn't have contours. Glyph " + self.layer.parent.name + " was spaced uses its own vertical range.\n"
self.referenceLayer = self.layer
else:
self.referenceLayer = self.layer
self.output += "WARNING: The reference glyph declared (" + self.engine.reference + ") doesn't exist. Glyph " + self.layer.parent.name + " was spaced uses its own vertical range.\n"
示例4: CFSTR
# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def CFSTR(strval):
return _objc.lookUpClass("NSString").stringWithString_(strval)
示例5: __getattr__
# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def __getattr__(self, name):
if name == "__all__":
# Load everything immediately
value = self.__calc_all()
self.__dict__[name] = value
return value
# First try parent module, as if we had done
# 'from parents import *'
for p in self.__parents:
try:
value = getattr(p, name)
except AttributeError:
pass
else:
self.__dict__[name] = value
if "__all__" in self.__dict__:
del self.__dict__["__all__"]
return value
if not _name_re.match(name):
# Name is not a valid identifier and cannot
# match.
raise AttributeError(name)
# Check if the name is a constant from
# the metadata files
try:
value = self.__get_constant(name)
except AttributeError:
pass
else:
self.__dict__[name] = value
if "__all__" in self.__dict__:
del self.__dict__["__all__"]
return value
# Then check if the name is class
try:
value = lookUpClass(name)
except nosuchclass_error:
pass
else:
self.__dict__[name] = value
if "__all__" in self.__dict__:
del self.__dict__["__all__"]
return value
# Finally give up and raise AttributeError
raise AttributeError(name)
示例6: send_OS_X_notify
# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def send_OS_X_notify(title, content, img_path):
'''发送Mac桌面通知'''
try:
from Foundation import (
NSDate, NSUserNotification, NSUserNotificationCenter)
from AppKit import NSImage
import objc
except ImportError:
logger.info('failed to init OSX notify!')
return
def swizzle(cls, SEL, func):
old_IMP = getattr(cls, SEL, None)
if old_IMP is None:
old_IMP = cls.instanceMethodForSelector_(SEL)
def wrapper(self, *args, **kwargs):
return func(self, old_IMP, *args, **kwargs)
new_IMP = objc.selector(wrapper, selector=old_IMP.selector,
signature=old_IMP.signature)
objc.classAddMethod(cls, SEL.encode(), new_IMP)
def swizzled_bundleIdentifier(self, original):
# Use iTunes icon for notification
return 'com.apple.itunes'
swizzle(objc.lookUpClass('NSBundle'),
'bundleIdentifier',
swizzled_bundleIdentifier)
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setSubtitle_(content)
notification.setInformativeText_('')
notification.setUserInfo_({})
if img_path is not None:
image = NSImage.alloc().initWithContentsOfFile_(img_path)
# notification.setContentImage_(image)
notification.set_identityImage_(image)
notification.setDeliveryDate_(
NSDate.dateWithTimeInterval_sinceDate_(0, NSDate.date())
)
NSUserNotificationCenter.defaultUserNotificationCenter().\
scheduleNotification_(notification)
logger.info('send notify success!')