<small id='286ye'></small><noframes id='286ye'>

  • <tfoot id='286ye'></tfoot>
  • <i id='286ye'><tr id='286ye'><dt id='286ye'><q id='286ye'><span id='286ye'><b id='286ye'><form id='286ye'><ins id='286ye'></ins><ul id='286ye'></ul><sub id='286ye'></sub></form><legend id='286ye'></legend><bdo id='286ye'><pre id='286ye'><center id='286ye'></center></pre></bdo></b><th id='286ye'></th></span></q></dt></tr></i><div id='286ye'><tfoot id='286ye'></tfoot><dl id='286ye'><fieldset id='286ye'></fieldset></dl></div>

        <bdo id='286ye'></bdo><ul id='286ye'></ul>

      1. <legend id='286ye'><style id='286ye'><dir id='286ye'><q id='286ye'></q></dir></style></legend>

        Python - 在应用程序中显示 Web 浏览器/iframe

        时间:2023-10-10
        • <bdo id='1v6h6'></bdo><ul id='1v6h6'></ul>
        • <tfoot id='1v6h6'></tfoot>
          • <i id='1v6h6'><tr id='1v6h6'><dt id='1v6h6'><q id='1v6h6'><span id='1v6h6'><b id='1v6h6'><form id='1v6h6'><ins id='1v6h6'></ins><ul id='1v6h6'></ul><sub id='1v6h6'></sub></form><legend id='1v6h6'></legend><bdo id='1v6h6'><pre id='1v6h6'><center id='1v6h6'></center></pre></bdo></b><th id='1v6h6'></th></span></q></dt></tr></i><div id='1v6h6'><tfoot id='1v6h6'></tfoot><dl id='1v6h6'><fieldset id='1v6h6'></fieldset></dl></div>

                  <tbody id='1v6h6'></tbody>

                  <small id='1v6h6'></small><noframes id='1v6h6'>

                  <legend id='1v6h6'><style id='1v6h6'><dir id='1v6h6'><q id='1v6h6'></q></dir></style></legend>
                  本文介绍了Python - 在应用程序中显示 Web 浏览器/iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个脚本,如果对人们回答问题有帮助的话,我正在使用 kivy.我想让它在运行时直接显示 iframe 之类的东西,而不是打开浏览器.例如这样的:

                  I have a script which if helpful to people answering questions, is using kivy. I want to have it show a iframe kind of thing right into it when run, instead of opening the browser. For example something like this:

                  def browser():
                      url = "google.com"
                      iframe(url)
                  browser()
                  

                  显然这不起作用,因为 python 不是 html.请记住,我不是想跑步这个脚本在网络上,但在 kivy 启动器上.正如预期的那样,它不应该打开浏览器,而是在脚本内置的框中显示页面.

                  Obviously this wouldnt work as python is not html. Keep in mind, I am not trying to run this script on the web, but on the kivy launcher. As intended, it should not open the webbrowser but instead show the page in a box built right into the script.

                  推荐答案

                  这是一个在Kivy Launcher"应用程序中运行的实际运行示例:

                  Here's an actual running example which works right inside the "Kivy Launcher" app:

                  import kivy                                                                                     
                  from kivy.app import App                                                                        
                  from kivy.lang import Builder                                                                   
                  from kivy.utils import platform                                                                 
                  from kivy.uix.widget import Widget                                                              
                  from kivy.clock import Clock                                                                    
                  from jnius import autoclass                                                                     
                  from android.runnable import run_on_ui_thread                                                   
                  
                  WebView = autoclass('android.webkit.WebView')                                                   
                  WebViewClient = autoclass('android.webkit.WebViewClient')                                       
                  activity = autoclass('org.renpy.android.PythonActivity').mActivity                              
                  
                  class Wv(Widget):                                                                               
                      def __init__(self, **kwargs):                                                               
                          super(Wv, self).__init__(**kwargs)                                                      
                          Clock.schedule_once(self.create_webview, 0)                                             
                  
                      @run_on_ui_thread                                                                           
                      def create_webview(self, *args):                                                            
                          webview = WebView(activity)                                                             
                          webview.getSettings().setJavaScriptEnabled(True)                                        
                          wvc = WebViewClient();                                                                  
                          webview.setWebViewClient(wvc);                                                          
                          activity.setContentView(webview)                                                        
                          webview.loadUrl('http://www.google.com')
                  
                  class ServiceApp(App):                                                                          
                      def build(self):                                                                            
                          return Wv()                                                                             
                  
                  if __name__ == '__main__':                                                                      
                      ServiceApp().run()
                  

                  这篇关于Python - 在应用程序中显示 Web 浏览器/iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将纯 python 中动态创建的按钮添加到用 Kivy 下一篇:Python/Kivy:从一个类调用函数到另一个类并在 Pyt

                  相关文章

                  最新文章

                  <tfoot id='yZujP'></tfoot>
                    <bdo id='yZujP'></bdo><ul id='yZujP'></ul>

                    <i id='yZujP'><tr id='yZujP'><dt id='yZujP'><q id='yZujP'><span id='yZujP'><b id='yZujP'><form id='yZujP'><ins id='yZujP'></ins><ul id='yZujP'></ul><sub id='yZujP'></sub></form><legend id='yZujP'></legend><bdo id='yZujP'><pre id='yZujP'><center id='yZujP'></center></pre></bdo></b><th id='yZujP'></th></span></q></dt></tr></i><div id='yZujP'><tfoot id='yZujP'></tfoot><dl id='yZujP'><fieldset id='yZujP'></fieldset></dl></div>
                    1. <small id='yZujP'></small><noframes id='yZujP'>

                      <legend id='yZujP'><style id='yZujP'><dir id='yZujP'><q id='yZujP'></q></dir></style></legend>