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


Python utils.platform方法代码示例

本文整理汇总了Python中kivy.utils.platform方法的典型用法代码示例。如果您正苦于以下问题:Python utils.platform方法的具体用法?Python utils.platform怎么用?Python utils.platform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.utils的用法示例。


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

示例1: fontscale

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def fontscale(self):
        '''Return the fontscale user preference. This value is 1 by default but
        can vary between 0.8 and 1.2.
        '''
        custom_fontscale = environ.get('KIVY_METRICS_FONTSCALE')
        if custom_fontscale:
            return float(custom_fontscale)

        if platform == 'android':
            from jnius import autoclass
            PythonActivity = autoclass('org.renpy.android.PythonActivity')
            config = PythonActivity.mActivity.getResources().getConfiguration()
            return config.fontScale

        return 1.0


#: Default instance of :class:`MetricsBase`, used everywhere in the code
#: .. versionadded:: 1.7.0 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:21,代码来源:metrics.py

示例2: build

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def build(self):
        self.log('start of log')
        if KIVYLAUNCHER_PATHS:
            self.paths.extend(KIVYLAUNCHER_PATHS.split(","))
        else:
            from jnius import autoclass
            Environment = autoclass('android.os.Environment')
            sdcard_path = Environment.getExternalStorageDirectory().getAbsolutePath()
            self.paths = [
                sdcard_path + "/kivy",
            ]

        self.root = Builder.load_string(KV)
        self.refresh_entries()

        if platform == 'android':
            from android.permissions import request_permissions, Permission
            request_permissions([Permission.READ_EXTERNAL_STORAGE]) 
开发者ID:kivy,项目名称:kivy-launcher,代码行数:20,代码来源:app.py

示例3: scan_qr

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def scan_qr(on_complete):
    if platform != 'android':
        return
    from jnius import autoclass
    from android import activity
    PythonActivity = autoclass('org.kivy.android.PythonActivity')
    SimpleScannerActivity = autoclass(
        "org.pythonindia.qr.SimpleScannerActivity")
    Intent = autoclass('android.content.Intent')
    intent = Intent(PythonActivity.mActivity, SimpleScannerActivity)

    def on_qr_result(requestCode, resultCode, intent):
        try:
            if resultCode == -1:  # RESULT_OK:
                #  this doesn't work due to some bug in jnius:
                # contents = intent.getStringExtra("text")
                String = autoclass("java.lang.String")
                contents = intent.getStringExtra(String("text"))
                on_complete(contents)
        finally:
            activity.unbind(on_activity_result=on_qr_result)
    activity.bind(on_activity_result=on_qr_result)
    PythonActivity.mActivity.startActivityForResult(intent, 0) 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:25,代码来源:__init__.py

示例4: reload_drives

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def reload_drives(self):
        nodes = [(node, node.text + node.path) for node in\
                 self._computer_node.nodes if isinstance(node, TreeLabel)]
        sigs = [s[1] for s in nodes]
        nodes_new = []
        sig_new = []
        for path, name in get_drives():
            if platform == 'win':
                text = u'{}({})'.format((name + ' ') if name else '', path)
            else:
                text = name
            nodes_new.append((text, path))
            sig_new.append(text + path + sep)
        for node, sig in nodes:
            if sig not in sig_new:
                self.remove_node(node)
        for text, path in nodes_new:
            if text + path + sep not in sigs:
                self.add_node(TreeLabel(text=text, path=path + sep),
                              self._computer_node) 
开发者ID:MaslowCNC,项目名称:GroundControl,代码行数:22,代码来源:fileBrowser.py

示例5: dpi

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def dpi(self):
        '''Return the DPI of the screen. Depending on the platform, the DPI can
        be taken from the Window provider (Desktop mainly) or from a
        platform-specific module (like android/ios).
        '''
        custom_dpi = environ.get('KIVY_DPI')
        if custom_dpi:
            return float(custom_dpi)

        if platform == 'android':
            import android
            return android.get_dpi()
        elif platform == 'ios':
            import ios
            return ios.get_dpi()

        # for all other platforms..
        from kivy.base import EventLoop
        EventLoop.ensure_window()
        return EventLoop.window.dpi 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:22,代码来源:metrics.py

示例6: density

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def density(self):
        '''Return the density of the screen. This value is 1 by default
        on desktops but varies on android depending on the screen.
        '''
        custom_density = environ.get('KIVY_METRICS_DENSITY')
        if custom_density:
            return float(custom_density)

        if platform == 'android':
            import jnius
            Hardware = jnius.autoclass('org.renpy.android.Hardware')
            return Hardware.metrics.scaledDensity
        elif platform == 'ios':
            # 0.75 is for mapping the same density as android tablet
            import ios
            return ios.get_scale() * 0.75
        elif platform == 'macosx':
            from kivy.base import EventLoop
            EventLoop.ensure_window()
            return  EventLoop.window.dpi / 96.

        return 1.0 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:24,代码来源:metrics.py

示例7: set_icon

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def set_icon(self, filename):
        if not exists(filename):
            return False
        try:
            if platform == 'win':
                try:
                    if self._set_icon_win(filename):
                        return True
                except:
                    # fallback on standard loading then.
                    pass

            # for all others platform, or if the ico is not available, use the
            # default way to set it.
            self._set_icon_standard(filename)
            super(WindowPygame, self).set_icon(filename)
        except:
            Logger.exception('WinPygame: unable to set icon') 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:20,代码来源:window_pygame.py

示例8: on_motion

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def on_motion(self, etype, me):
        '''Event called when a Motion Event is received.

        :Parameters:
            `etype`: str
                One of 'begin', 'update', 'end'
            `me`: :class:`~kivy.input.motionevent.MotionEvent`
                The Motion Event currently dispatched.
        '''
        if me.is_touch:
            w, h = self.system_size
            if platform == 'ios':
                w, h = self.size
            me.scale_for_screen(w, h, rotation=self._rotation,
                                smode=self.softinput_mode,
                                kheight=self.keyboard_height)
            if etype == 'begin':
                self.dispatch('on_touch_down', me)
            elif etype == 'update':
                self.dispatch('on_touch_move', me)
            elif etype == 'end':
                self.dispatch('on_touch_up', me)
                FocusBehavior._handle_post_on_touch_up(me) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:25,代码来源:__init__.py

示例9: on_keyboard

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def on_keyboard(self, key, scancode=None, codepoint=None,
                    modifier=None, **kwargs):
        '''Event called when keyboard is used.

        .. warning::
            Some providers may omit `scancode`, `codepoint` and/or `modifier`!
        '''
        if 'unicode' in kwargs:
            Logger.warning("The use of the unicode parameter is deprecated, "
                           "and will be removed in future versions. Use "
                           "codepoint instead, which has identical "
                           "semantics.")

        # Quit if user presses ESC or the typical OSX shortcuts CMD+q or CMD+w
        # TODO If just CMD+w is pressed, only the window should be closed.
        is_osx = platform == 'darwin'
        if WindowBase.on_keyboard.exit_on_escape:
            if key == 27 or all([is_osx, key in [113, 119], modifier == 1024]):
                if not self.dispatch('on_request_close', source='keyboard'):
                    stopTouchApp()
                    self.close()
                    return True 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:24,代码来源:__init__.py

示例10: _ensure_clipboard

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def _ensure_clipboard(self):
        ''' Ensure that the clipboard has been properly initialised.
        '''

        if hasattr(self, '_clip_mime_type'):
            return

        if platform == 'win':
            self._clip_mime_type = 'text/plain;charset=utf-8'
            # windows clipboard uses a utf-16 little endian encoding
            self._encoding = 'utf-16-le'
        elif platform == 'linux':
            self._clip_mime_type = 'text/plain;charset=utf-8'
            self._encoding = 'utf-8'
        else:
            self._clip_mime_type = 'text/plain'
            self._encoding = 'utf-8' 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:19,代码来源:__init__.py

示例11: open_url

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def open_url(url):
    if platform == 'android':
        ''' Open a webpage in the default Android browser.  '''
        from jnius import autoclass, cast
        context = autoclass('org.renpy.android.PythonActivity').mActivity
        Uri = autoclass('android.net.Uri')
        Intent = autoclass('android.content.Intent')

        intent = Intent()
        intent.setAction(Intent.ACTION_VIEW)
        intent.setData(Uri.parse(url))
        currentActivity = cast('android.app.Activity', context)
        currentActivity.startActivity(intent)
    else:
        import webbrowser
        webbrowser.open(url) 
开发者ID:metamarcdw,项目名称:nowallet,代码行数:18,代码来源:main.py

示例12: __init__

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def __init__(self, settings, **kwargs):
        Builder.load_file(PREFERENCES_KV_FILE)
        super(PreferencesView, self).__init__(**kwargs)
        self.settings = settings
        self.base_dir = kwargs.get('base_dir')
        self.register_event_type('on_pref_change')

        self.settings_view = SettingsWithNoMenu()
        self.settings_view.bind(on_config_change=self._on_preferences_change)

        # So, Kivy's Settings object doesn't allow you to add multiple json panels at a time, only 1. If you add
        # multiple, the last one added 'wins'. So what we do is load the settings JSON ourselves and then merge it
        # with any platform-specific settings (if applicable). It's silly, but works.
        settings_json = json.loads(open(os.path.join(self.base_dir, 'resource', 'settings', 'settings.json')).read())

        if platform == 'android':
            android_settings_json = json.loads(open(os.path.join(self.base_dir, 'resource', 'settings', 'android_settings.json')).read())
            settings_json = settings_json + android_settings_json

        self.settings_view.add_json_panel('Preferences', self.settings.userPrefs.config, data=json.dumps(settings_json))

        self.content = kvFind(self, 'rcid', 'preferences')
        self.content.add_widget(self.settings_view) 
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:25,代码来源:preferences.py

示例13: init_ui

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def init_ui(game):
    view = Widget()

    _heading(game, view)
    _notes(game, view)
    _scales(game, view)
    _tuning(game, view)

    view.add_widget(game)

    if platform in ('android', 'ios'):
        from kivy.core.window import Window
        from kivy.uix.scrollview import ScrollView

        app_view = view
        app_view.size = (960, 540)
        app_view.size_hint = (None, None)

        view = ScrollView(size=Window.size)
        view.effect_cls = ScrollEffect
        view.add_widget(app_view)

    return view 
开发者ID:mvasilkov,项目名称:kivy-2014,代码行数:25,代码来源:ui.py

示例14: share

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def share(self):
        if platform() == 'android': #check if the app is on Android
            # read more here: http://developer.android.com/training/sharing/send.html
            PythonActivity = autoclass('org.renpy.android.PythonActivity') #request the activity instance
            Intent = autoclass('android.content.Intent') # get the Android Intend class

            String = autoclass('java.lang.String') # get the Java object

            intent = Intent() # create a new Android Intent
            intent.setAction(Intent.ACTION_SEND) #set the action
            # to send a message, it need to be a Java char array. So we use the cast to convert and Java String to a Java Char array
            intent.putExtra(Intent.EXTRA_SUBJECT, cast('java.lang.CharSequence', String('Fast Perception')))
            intent.putExtra(Intent.EXTRA_TEXT, cast('java.lang.CharSequence', String('Wow, I just scored %d on Fast Perception. Check this game: https://play.google.com/store/apps/details?id=com.aronbordin.fastperception' % (self.best_score))))

            intent.setType('text/plain') #text message

            currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
            currentActivity.startActivity(intent) # show the intent in the game activity

    # will be called when our screen be displayed 
开发者ID:aron-bordin,项目名称:Kivy-Tutorials,代码行数:22,代码来源:main.py

示例15: share

# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import platform [as 别名]
def share(self):
        if platform() == 'android': #check if the app is on Android
            # read more here: http://developer.android.com/training/sharing/send.html
           
            PythonActivity = autoclass('org.renpy.android.PythonActivity') #request the Kivy activity instance
            Intent = autoclass('android.content.Intent') # get the Android Intend class

            String = autoclass('java.lang.String') # get the Java object

            intent = Intent() # create a new Android Intent
            intent.setAction(Intent.ACTION_SEND) #set the action

            # to send a message, it need to be a Java char array. So we use the cast to convert and Java String to a Java Char array
            intent.putExtra(Intent.EXTRA_SUBJECT, cast('java.lang.CharSequence', String('Byte::Debugger() Tutorial #7')))
            intent.putExtra(Intent.EXTRA_TEXT, cast('java.lang.CharSequence', String("Testing Byte::Debugger() Tutorial #7, with Python for Android")))

            intent.setType('text/plain') #text message

            currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
            currentActivity.startActivity(intent) # show the intent in the game activity 
开发者ID:aron-bordin,项目名称:Kivy-Tutorials,代码行数:22,代码来源:main.py


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