当前位置: 首页>>代码示例>>Python>>正文


Python objc.lookUpClass方法代码示例

本文整理汇总了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 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:24,代码来源:_static.py

示例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) 
开发者ID:justvanrossum,项目名称:fontgoggles,代码行数:13,代码来源:misc.py

示例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" 
开发者ID:huertatipografica,项目名称:HTLetterspacer,代码行数:35,代码来源:HT_LetterSpacer_script.py

示例4: CFSTR

# 需要导入模块: import objc [as 别名]
# 或者: from objc import lookUpClass [as 别名]
def CFSTR(strval):
    return _objc.lookUpClass("NSString").stringWithString_(strval) 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:4,代码来源:_static.py

示例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) 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:54,代码来源:_lazyimport.py

示例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!') 
开发者ID:taizilongxu,项目名称:douban.fm,代码行数:48,代码来源:notification.py


注:本文中的objc.lookUpClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。