本文整理汇总了Python中kivy.platform方法的典型用法代码示例。如果您正苦于以下问题:Python kivy.platform方法的具体用法?Python kivy.platform怎么用?Python kivy.platform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy
的用法示例。
在下文中一共展示了kivy.platform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_data_dir
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def get_user_data_dir(name):
# Determine and return the user_data_dir.
data_dir = ""
if platform == 'ios':
raise NotImplemented()
elif platform == 'android':
raise NotImplemented()
elif platform == 'win':
data_dir = os.path.join(os.environ['APPDATA'], name)
elif platform == 'macosx':
data_dir = '~/Library/Application Support/{}'.format(name)
data_dir = expanduser(data_dir)
else: # _platform == 'linux' or anything else...:
data_dir = os.environ.get('XDG_CONFIG_HOME', '~/.config')
data_dir = expanduser(join(data_dir, name))
if not exists(data_dir):
os.mkdir(data_dir)
return data_dir
示例2: __init__
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def __init__(self, *args, **kwargs):
super(InterpreterInput, self).__init__(*args, **kwargs)
self.register_event_type('on_request_completions')
self.register_event_type('on_clear_completions')
self.register_event_type('on_get_completions')
if platform != 'android':
from pygments.lexers import PythonLexer
self.lexer = PythonLexer()
App.get_running_app().bind(on_pause=self.on_pause)
# self.text = '''for i in range(5):
# print(i)
# time.sleep(1)'''
示例3: on_setting__rotation
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def on_setting__rotation(self, instance, value):
print('new rotation is', value)
if platform != 'android':
return
if value not in ('portrait', 'landscape', 'auto'):
print('Orientation error: invalid setting received')
from jnius import autoclass
ActivityInfo = autoclass('android.content.pm.ActivityInfo')
activity = autoclass('org.kivy.android.PythonActivity').mActivity
if value == 'portrait':
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT)
if value == 'landscape':
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE)
if value == 'auto':
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER)
示例4: comms_factory
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def comms_factory(device, conn_type):
# Connection type can be overridden by user or for testing purposes
if conn_type is not None:
conn_type = conn_type.lower()
if conn_type == 'bluetooth':
return android_comm(device)
if conn_type == 'wifi':
return socket_comm(device)
if conn_type == 'serial':
return serial_comm(device)
else:
if platform == 'android':
return android_comm(device)
elif platform == 'ios':
return socket_comm(device)
else:
return serial_comm(device)
示例5: start_interpreter
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def start_interpreter(self, thread_name='default'):
# if thread_name == 'interpreter':
# return
print('trying to start interpreter', self.service_name)
interpreter_script_path = join(dirname(realpath(__file__)),
'interpreter_subprocess',
'interpreter.py')
# prepare settings to send to interpreter
# throttle_output = '1' if App.get_running_app().setting__throttle_output else '0'
throttle_output = '1' if self.throttle_output else '0'
use_thread = '1' if self.use_thread else '0'
argument = ('throttle_output={}:use_thread={}:'
'send_port={}:receive_port={}').format(
throttle_output, use_thread,
self.receive_port, self.interpreter_port)
if platform == 'android':
from jnius import autoclass
service = autoclass('{}.Service{}'.format(package_name, self.service_name))
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
# service.start(mActivity, argument, thread_name)
service.start(mActivity, argument)
print('did service start', service, mActivity)
else:
# This may not actually work everywhere, but let's assume it does
print('starting subprocess')
python_name = 'python{}'.format(sys.version_info.major)
print('python name is', python_name)
os.environ['PYTHON_SERVICE_ARGUMENT'] = argument
s = subprocess.Popen([python_name, '{}'.format(interpreter_script_path)])
App.get_running_app().subprocesses.append(s)
self.subprocess = s
pass
示例6: restart
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def restart(self):
if platform == 'android':
from jnius import autoclass
service = autoclass('{}.Service{}'.format(package_name, self.service_name))
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
service.stop(mActivity)
self.start_interpreter(self.thread_name)
else:
self.subprocess.kill()
self.start_interpreter(self.thread_name)
self.lock_input = True
self.interpreter_state = 'restarting'
Clock.unschedule
Clock.schedule_interval(self.ping, 0.3)
示例7: go_home
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def go_home(self):
self.select(None)
if platform == 'android':
from jnius import autoclass
Environment = autoclass('android.os.Environment')
home = Environment.getExternalStorageDirectory().getAbsolutePath()
else:
home = expanduser('~')
self.folder = home
示例8: build
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def build(self):
self.settings_retrieved = False # used to prevent setting
# updates until they have
# been fetched from the file
Window.clearcolor = (1, 1, 1, 1)
Window.softinput_mode = 'pan'
self.parse_args()
Clock.schedule_once(self.android_setup, 0)
Clock.schedule_once(self.retrieve_settings, 0)
if platform == 'android':
settings_path = '../settings.json'
else:
settings_path = join(abspath(dirname(__file__)), '..', 'settings.json')
self.store = SettingsStore(settings_path)
# Retrieve the input throttling argument so that it can be
# passed to the service immediately
self.setting__throttle_output = self.store.get(
'setting__throttle_output',
{'value': self.setting__throttle_output_default})['value']
Window.bind(on_keyboard=self.key_input)
for attr in dir(self):
if attr.startswith('setting__') and not attr.endswith('_default'):
self.bind(**{attr: partial(self.setting_updated, attr)})
self.manager = Manager()
return self.manager
示例9: back_button_leave_app
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def back_button_leave_app(self):
if platform != 'android':
return
from jnius import autoclass
activity = autoclass('org.kivy.android.PythonActivity')
activity.moveTaskToBack(True)
示例10: __repr__
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def __repr__(self):
return 'platform name: \'{platform}\' from: \n{instance}'.format(
platform=self._get_platform(),
instance=super(Platform, self).__repr__()
)
示例11: user_data_dir
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def user_data_dir(self):
# this is a workaround for a kivy bug in which /sdcard is the hardcoded path for
# the user dir. This fails on Android 7.0 systems.
# this function should be removed when the bug is fixed in kivy.
if kivy.platform == 'android':
from jnius import autoclass
env = autoclass('android.os.Environment')
data_dir = os.path.join(env.getExternalStorageDirectory().getPath(), self.name)
else:
data_dir = super(RaceCaptureApp, self).user_data_dir
return data_dir
示例12: processArgs
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def processArgs(self):
parser = argparse.ArgumentParser(description='Autosport Labs Race Capture App')
parser.add_argument('-p', '--port', help='Port', required=False)
parser.add_argument('--telemetryhost', help='Telemetry host', required=False)
parser.add_argument('--conn_type', help='Connection type', required=False, choices=['bt', 'serial', 'wifi'])
if sys.platform == 'win32':
parser.add_argument('--multiprocessing-fork', required=False, action='store_true')
self.app_args = vars(parser.parse_args())
示例13: build
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def build(self):
self.init_view_builders()
Builder.load_file('racecapture.kv')
root = self.root
status_bar = root.ids.status_bar
status_bar.bind(on_main_menu=self.on_main_menu)
self.status_bar = status_bar
root.ids.main_menu.bind(on_main_menu_item=self.on_main_menu_item)
self.mainNav = root.ids.main_nav
# reveal_below_anim
# reveal_below_simple
# slide_above_anim
# slide_above_simple
# fade_in
self.mainNav.anim_type = 'slide_above_anim'
rc_api = self._rc_api
rc_api.on_progress = lambda value: status_bar.dispatch('on_progress', value)
rc_api.on_rx = lambda value: status_bar.dispatch('on_data_rx', value)
screenMgr = root.ids.main
# NoTransition
# SlideTransition
# SwapTransition
# FadeTransition
# WipeTransition
# FallOutTransition
# RiseInTransition
screenMgr.transition = NoTransition() # FallOutTransition() # NoTransition()
self.screenMgr = screenMgr
self.icon = ('resource/images/app_icon_128x128.ico' if sys.platform == 'win32' else 'resource/images/app_icon_128x128.png')
Clock.schedule_once(lambda dt: self.post_launch(), 1.0)
示例14: is_android
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def is_android():
return True if platform == 'android' else False
示例15: is_windows
# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import platform [as 别名]
def is_windows():
return True if platform == 'win' else False