本文整理汇总了Python中pyobjus.autoclass函数的典型用法代码示例。如果您正苦于以下问题:Python autoclass函数的具体用法?Python autoclass怎么用?Python autoclass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了autoclass函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: load_framework
'''
Mac OS X file chooser
---------------------
'''
from plyer.facades import FileChooser
from pyobjus import autoclass, objc_arr, objc_str
from pyobjus.dylib_manager import load_framework, INCLUDE
load_framework(INCLUDE.AppKit)
NSURL = autoclass('NSURL')
NSOpenPanel = autoclass('NSOpenPanel')
NSSavePanel = autoclass('NSSavePanel')
NSOKButton = 1
class MacFileChooser(object):
'''A native implementation of file chooser dialogs using Apple's API
through pyobjus.
Not implemented features:
* filters (partial, wildcards are converted to extensions if possible.
Pass the Mac-specific "use_extensions" if you can provide
Mac OS X-compatible to avoid automatic conversion)
* multiple (only for save dialog. Available in open dialog)
* icon
* preview
'''
mode = "open"
path = None
开发者ID:aakash013srivastava,项目名称:plyer,代码行数:31,代码来源:filechooser.py
示例17: SystemError
__all__ = ('ClipboardNSPaste', )
from kivy.core.clipboard import ClipboardBase
from kivy.utils import platform
if platform != 'macosx':
raise SystemError('Unsupported platform for appkit clipboard.')
try:
from pyobjus import autoclass
from pyobjus.dylib_manager import load_framework, INCLUDE
load_framework(INCLUDE.AppKit)
except ImportError:
raise SystemError('Pyobjus not installed. Please run the following'
' command to install it. `pip install --user pyobjus`')
NSPasteboard = autoclass('NSPasteboard')
NSString = autoclass('NSString')
class ClipboardNSPaste(ClipboardBase):
def __init__(self):
super(ClipboardNSPaste, self).__init__()
self._clipboard = NSPasteboard.generalPasteboard()
def get(self, mimetype='text/plain'):
pb = self._clipboard
data = pb.stringForType_('public.utf8-plain-text')
if not data:
return ""
return data.UTF8String()
开发者ID:akshayaurora,项目名称:kivy,代码行数:31,代码来源:clipboard_nspaste.py
示例18: autoclass
# Note that we arent specify type of structs, so they types will be missing in method signatures
# typedef struct {
# float a;
# int b;
# NSRect rect;
# } unknown_str_new;
# typedef struct {
# int a;
# int b;
# NSRect rect;
# unknown_str_new u_str;
# } unknown_str;
Car = autoclass('Car')
car = Car.alloc().init()
# Let's play know. Suppose that we have defined following objective c method:
# - (unknown_str) makeUnknownStr {
# unknown_str str;
# str.a = 10;
# str.rect = NSMakeRect(20, 30, 40, 50);
# str.u_str.a = 2.0;
# str.u_str.b = 4;
# return str;
# }
# Purpose of this method is to make unknown type struct, and assing some values to it's members
# If you see debug logs of pyobjus, you will see that method returns following type:
# {?=ii{CGRect={CGPoint=dd}{CGSize=dd}}{?=fi{CGRect={CGPoint=dd}{CGSize=dd}}}}
开发者ID:cnsoft,项目名称:pyobjus,代码行数:31,代码来源:unknown_type.py
示例19: setUp
def setUp(self):
global Car, car
load_dylib('testlib.dylib', usr_path=False)
Car = autoclass('Car')
car = Car.alloc().init()
开发者ID:kivy,项目名称:pyobjus,代码行数:5,代码来源:test_unknown_types.py
示例20: load_framework
from pyobjus import autoclass
from pyobjus.dylib_manager import load_framework, INCLUDE
load_framework(INCLUDE.AppKit)
# get both nsalert and nsstring class
NSAlert = autoclass('NSAlert')
NSString = autoclass('NSString')
ns = lambda x: NSString.alloc().initWithUTF8String_(x)
alert = NSAlert.alloc().init()
alert.setMessageText_(ns('Hello world from python!'))
alert.addButtonWithTitle_(NSString.stringWithUTF8String_("OK"))
alert.addButtonWithTitle_(NSString.stringWithUTF8String_("Cancel"))
alert.runModal()
开发者ID:Nesrider,项目名称:pyobjus,代码行数:15,代码来源:ns_alert.py
注:本文中的pyobjus.autoclass函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论