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


Python pyobjus.autoclass函数代码示例

本文整理汇总了Python中pyobjus.autoclass函数的典型用法代码示例。如果您正苦于以下问题:Python autoclass函数的具体用法?Python autoclass怎么用?Python autoclass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了autoclass函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open_url

def open_url(url):

    if url.startswith("file:"):
        raise Exception("Opening file urls is not supported: " + url)

    try:
        NSURL = autoclass('NSURL')
        UIApplication = autoclass("UIApplication")

        nsurl = NSURL.URLWithString_(objc_str(url))
        UIApplication.sharedApplication().openURL_(nsurl)
    except:
        import traceback
        traceback.print_exc()
        raise
开发者ID:renpy,项目名称:renios,代码行数:15,代码来源:iossupport.py

示例2: setUp

 def setUp(self):
     global NSURL, NSURLConnection, NSURLRequest
     load_framework(INCLUDE.AppKit)
     load_framework(INCLUDE.Foundation)
     NSURL = autoclass('NSURL')
     NSURLConnection = autoclass('NSURLConnection')
     NSURLRequest = autoclass('NSURLRequest')
开发者ID:kivy,项目名称:pyobjus,代码行数:7,代码来源:test_delegate.py

示例3: detect_user_locale

def detect_user_locale():
    import locale
    if renpy.windows:
        import ctypes
        windll = ctypes.windll.kernel32
        locale_name = locale.windows_locale.get(windll.GetUserDefaultUILanguage())
    elif renpy.android:
        from jnius import autoclass
        Locale = autoclass('java.util.Locale')
        locale_name = str(Locale.getDefault().getLanguage())
    elif renpy.ios:
        import pyobjus
        NSLocale = pyobjus.autoclass("NSLocale")
        languages = NSLocale.preferredLanguages()
        locale_name = languages.objectAtIndex_(0).UTF8String().decode("utf-8")
        locale_name.replace("-", "_")
    else:
        locale_name = locale.getdefaultlocale()
        if locale_name is not None:
            locale_name = locale_name[0]

    if locale_name is None:
        return None, None

    normalize = locale.normalize(locale_name)
    if normalize == locale_name:
        language = region = locale_name
    else:
        locale_name = normalize
        if '.' in locale_name:
            locale_name, _ = locale_name.split('.', 1)
        language, region = locale_name.lower().split("_")
    return language, region
开发者ID:renpy,项目名称:renpy,代码行数:33,代码来源:__init__.py

示例4: centralManager_didConnectPeripheral_

 def centralManager_didConnectPeripheral_(self, central, peripheral):
     if not peripheral.name.UTF8String():
         return
     peripheral.delegate = self
     CBUUID = autoclass('CBUUID')
     service = CBUUID.UUIDWithString_('1901')
     peripheral.discoverServices_([service])
开发者ID:TangibleDisplay,项目名称:twiz,代码行数:7,代码来源:osx_ble.py

示例5: create

 def create(self):
     self.callback = None
     self.peripherals = {}
     load_framework(INCLUDE.IOBluetooth)
     CBCentralManager = autoclass('CBCentralManager')
     self.central = CBCentralManager.alloc().initWithDelegate_queue_(
         self, None)
开发者ID:TangibleDisplay,项目名称:twiz,代码行数:7,代码来源:osx_ble.py

示例6: create_webview

 def create_webview(self, *args):
     from pyobjus import autoclass, objc_str
     ObjcClass = autoclass('ObjcClassINSD')
     self.o_instance = ObjcClass.alloc().init()
     self.o_instance.aParam1 = objc_str(self._url)
     self.o_instance.openWebView()
     self._localserve.dispatch('on_webview')
开发者ID:insiderr,项目名称:insiderr-app,代码行数:7,代码来源:linkedin.py

示例7: run

def run():
    Bridge = autoclass('bridge')
    br = Bridge.alloc().init()
    br.motionManager.setAccelerometerUpdateInterval_(0.1)
    br.startAccelerometer()

    for i in range(10000):
        print 'x: {0} y: {1} z: {2}'.format(br.ac_x, br.ac_y, br.ac_z)
开发者ID:tshirtman,项目名称:pyconfr-2013-kivy,代码行数:8,代码来源:objus.py

示例8: load_framework

def load_framework(framework):
    ''' Function for loading frameworks

    Args:
        framework: Framework to load

    Raises:
        ObjcException if it can't load framework
    '''
    NSBundle = autoclass('NSBundle')
    ns_framework = autoclass('NSString').stringWithUTF8String_(framework)
    bundle = NSBundle.bundleWithPath_(ns_framework)
    try:
        if bundle.load():
            dprint("Framework {0} succesufully loaded!".format(framework))
    except:
        raise ObjcException('Error while loading {0} framework'.format(framework))
开发者ID:kivy,项目名称:pyobjus,代码行数:17,代码来源:dylib_manager.py

示例9: test_basic_properties

    def test_basic_properties(self):
        car.propInt = 12345
        self.assertEqual(car.propInt, 12345)

        car.propDouble = 3456.2345
        self.assertEqual(car.propDouble, 3456.2345)

        # car.prop_double_ptr = 333.444
        # self.assertEqual(dereference(car.prop_double_ptr), 333.444)

        car.propNSString = autoclass('NSString').stringWithUTF8String_('string for test')
        self.assertEqual(car.propNSString.UTF8String(), 'string for test')
开发者ID:kivy,项目名称:pyobjus,代码行数:12,代码来源:test_properties.py

示例10: test_carray_class

 def test_carray_class(self):
     NSNumber = autoclass("NSNumber")
     nsnumber_class = NSNumber.oclass()
     nsnumber_class_array = [nsnumber_class for i in xrange(0, 10)]
     _instance.setClassValues_(nsnumber_class_array)
     returned_classes = dereference(_instance.getClassValues(), of_type=CArray, return_count=10)
     returned_classes_WithCount = dereference(_instance.getClassValuesWithCount_(CArrayCount), of_type=CArray)
     flag = True
     for i in xrange(len(returned_classes_WithCount)):
         if NSNumber.isKindOfClass_(returned_classes_WithCount[i]) == False:
             flag = False
     self.assertEquals(flag, True)
开发者ID:Nesrider,项目名称:pyobjus,代码行数:12,代码来源:test_carray.py

示例11: __init__

 def __init__(self, **kwargs):
     super(IOSKeyboard, self).__init__()
     self.kheight = 0
     NSNotificationCenter = autoclass("NSNotificationCenter")
     center = NSNotificationCenter.defaultCenter()
     center.addObserver_selector_name_object_(
         self, selector("keyboardWillShow"),
         "UIKeyboardWillShowNotification",
         None)
     center.addObserver_selector_name_object_(
         self, selector("keyboardDidHide"),
         "UIKeyboardDidHideNotification",
         None)
开发者ID:kivy,项目名称:pyobjus,代码行数:13,代码来源:test_delegate.py

示例12: _thread_handle_request

 def _thread_handle_request(self, *largs):
     try:
         self.httpd.handle_request()
         self.webviewwidget.remove()
         self.query_params = self.httpd.query_params
         self.httpd.server_close()
         print 'request recieved'
     except:
         pass
     self.dispatch('on_request_served')
     if platform == "android":
         from jnius import autoclass
         try:
             Thread = autoclass('java.lang.Thread')
             Thread.currentThread().join()
         except:
             pass
开发者ID:insiderr,项目名称:insiderr-app,代码行数:17,代码来源:linkedin.py

示例13: _enumerate_osx

def _enumerate_osx():
    from pyobjus import autoclass
    from pyobjus.dylib_manager import load_framework, INCLUDE
    load_framework(INCLUDE.AppKit)

    screens = autoclass('NSScreen').screens()
    monitors = []

    for i in range(screens.count()):
        f = screens.objectAtIndex_(i).frame
        if callable(f):
            f = f()

        monitors.append(
            Monitor(f.origin.x, f.origin.y, f.size.width, f.size.height))

    return monitors
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:17,代码来源:screeninfo.py

示例14: test_carray_object

 def test_carray_object(self):
     NSNumber = autoclass("NSNumber")
     ns_number_array = list()
     for i in xrange(0, 10):
         ns_number_array.append(NSNumber.alloc().initWithInt_(i))
     py_ints = [i for i in xrange(0,10)]
     _instance.setNSNumberValues_(ns_number_array)
     nsnumber_ptr_array = _instance.getNSNumberValues()
     returned_nsnumbers = dereference(nsnumber_ptr_array, of_type=CArray, return_count=10)
     returned_ints = list()
     for i in xrange(len(returned_nsnumbers)):
         returned_ints.append(returned_nsnumbers[i].intValue())
     returned_nsnumbers_WithCount = dereference(_instance.getNSNumberValuesWithCount_(CArrayCount), of_type=CArray)
     returned_ints_WithCount = list()
     for i in xrange(len(returned_nsnumbers_WithCount)):
         returned_ints_WithCount.append(returned_nsnumbers_WithCount[i].intValue())
     self.assertEquals(returned_ints, py_ints)
     self.assertEquals(returned_ints_WithCount, py_ints)
开发者ID:Nesrider,项目名称:pyobjus,代码行数:18,代码来源:test_carray.py

示例15: path_to_saves

def path_to_saves(gamedir, save_directory=None):
    import renpy  # @UnresolvedImport

    if save_directory is None:
        save_directory = renpy.config.save_directory
        save_directory = renpy.exports.fsencode(save_directory)

    # Makes sure the permissions are right on the save directory.
    def test_writable(d):
        try:
            fn = os.path.join(d, "test.txt")
            open(fn, "w").close()
            open(fn, "r").close()
            os.unlink(fn)
            return True
        except:
            return False

    # Android.
    if renpy.android:
        paths = [
            os.path.join(os.environ["ANDROID_OLD_PUBLIC"], "game/saves"),
            os.path.join(os.environ["ANDROID_PRIVATE"], "saves"),
            os.path.join(os.environ["ANDROID_PUBLIC"], "saves"),
            ]

        for rv in paths:
            if os.path.isdir(rv) and test_writable(rv):
                break

        print("Saving to", rv)

        # We return the last path as the default.

        return rv

    if renpy.ios:
        from pyobjus import autoclass
        from pyobjus.objc_py_types import enum

        NSSearchPathDirectory = enum("NSSearchPathDirectory", NSDocumentDirectory=9)
        NSSearchPathDomainMask = enum("NSSearchPathDomainMask", NSUserDomainMask=1)

        NSFileManager = autoclass('NSFileManager')
        manager = NSFileManager.defaultManager()
        url = manager.URLsForDirectory_inDomains_(
            NSSearchPathDirectory.NSDocumentDirectory,
            NSSearchPathDomainMask.NSUserDomainMask,
            ).lastObject()

        # url.path seems to change type based on iOS version, for some reason.
        try:
            rv = url.path().UTF8String().decode("utf-8")
        except:
            rv = url.path.UTF8String().decode("utf-8")

        print("Saving to", rv)
        return rv

    # No save directory given.
    if not save_directory:
        return gamedir + "/saves"

    # Search the path above Ren'Py for a directory named "Ren'Py Data".
    # If it exists, then use that for our save directory.
    path = renpy.config.renpy_base

    while True:
        if os.path.isdir(path + "/Ren'Py Data"):
            return path + "/Ren'Py Data/" + save_directory

        newpath = os.path.dirname(path)
        if path == newpath:
            break
        path = newpath

    # Otherwise, put the saves in a platform-specific location.
    if renpy.macintosh:
        rv = "~/Library/RenPy/" + save_directory
        return os.path.expanduser(rv)

    elif renpy.windows:
        if 'APPDATA' in os.environ:
            return os.environ['APPDATA'] + "/RenPy/" + save_directory
        else:
            rv = "~/RenPy/" + renpy.config.save_directory
            return os.path.expanduser(rv)

    else:
        rv = "~/.renpy/" + save_directory
        return os.path.expanduser(rv)
开发者ID:Saketai,项目名称:renpy,代码行数:91,代码来源:renpy.py


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