本文整理匯總了Python中kivy.utils方法的典型用法代碼示例。如果您正苦於以下問題:Python kivy.utils方法的具體用法?Python kivy.utils怎麽用?Python kivy.utils使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kivy
的用法示例。
在下文中一共展示了kivy.utils方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: runAndroid
# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import utils [as 別名]
def runAndroid(ga):
import kivy
from kivy.app import App
from kivy.utils import platform
from kivy.uix.widget import Widget
from kivy.clock import Clock
from kivy.logger import Logger
def run_on_ui_thread(arg):
pass
webView = None
webViewClient = None
#~ webChromeClient = None
activity = None
if platform == 'android':
from jnius import autoclass
from android.runnable import run_on_ui_thread
webView = autoclass('android.webkit.WebView')
webViewClient = autoclass('android.webkit.WebViewClient')
#~ webChromeClient = autoclass('android.webkit.WebChromeClient')
activity = autoclass('org.kivy.android.PythonActivity').mActivity
class Wv(Widget):
def __init__(self, guyWindow ):
self.f2 = self.create_webview # important
super(Wv, self).__init__()
self.visible = False
def exit(v):
activity.finish()
App.get_running_app().stop()
os._exit(0)
guyWindow._callbackExit = exit
self.ws=WebServer( guyWindow )
self.ws.start()
Clock.schedule_once(self.create_webview, 0)
@run_on_ui_thread
def create_webview(self, *args):
webview = webView(activity)
webview.getSettings().setJavaScriptEnabled(True)
webview.getSettings().setDomStorageEnabled(True)
webview.setWebViewClient(webViewClient())
#~ webview.setWebChromeClient(webChromeClient())
activity.setContentView(webview)
webview.loadUrl(self.ws.startPage)
class ServiceApp(App):
def build(self):
return Wv( ga )
ServiceApp().run()