2

The application compiles without problems, but when the application is executed it closes

version:

kivi - 1.10.0 cython: 0.28.6 python: 3.7.1

main.py


from kivy.app import App

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.kivy.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):
        pass

class ServiceApp(App):
    def build(self):
        return Wv()


if __name__ == '__main__':
    ServiceApp().run()

this is error:

Attribute error: 'Wv' object has no attribute 'f2'

Francisco
  • 539
  • 2
  • 8
  • 25
  • Is this all your code? Also post the full traceback. – inclement Jul 05 '19 at 19:30
  • yes, this is all the code, the problem is in the decorator "run_on_ui_thread" that is in the android module in runnable.py https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/ recipes / android / src / android / runnable.py but I do not understand why this error happens, only this error happens if I inherit from widget – Francisco Jul 06 '19 at 23:35
  • Post the full traceback. – inclement Jul 07 '19 at 10:01

1 Answers1

1

Get that create_webview out of the class and it'll work fine. Since you're using the decorator on a class method, it's searching for f2 within the class itself.

watney
  • 141
  • 1
  • 5