简体   繁体   English

Kivy Builder: AttributeError: 'NoneType' 对象没有属性 'text'

[英]Kivy Buildozer: AttributeError: 'NoneType' object has no attribute 'text'

i am testing Kivy with Buildozer to make an small app for my Android Device.我正在使用 Buildozer 测试 Kivy,以便为我的 Android 设备制作一个小应用程序。 On my PC everythink is running correctly.在我的电脑上,everythink 运行正常。 But when i want to create the APK with Buildozer everytime i get the Error AttributeError: 'NoneType' object has no attribute 'text'但是,当我每次收到错误AttributeError: 'NoneType' object has no attribute 'text'时,我都想使用 Buildozer 创建 APK

I googled a lot of times, but i could not find an answer to my question.我用谷歌搜索了很多次,但我找不到我的问题的答案。

Does anyone has a hint for me?有人对我有提示吗?

Would be great.会很好。

Thank You!谢谢你!

main.py:主要.py:

import kivy
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout  
from kivy.uix.textinput import TextInput  
import random
from kivy.clock import Clock
from kivy.properties import ObjectProperty
import requests
import json

def login (name,password):
    url_login = 'URL'
    payload = {'email': name, 'password': password}
    headers = {'content-type': 'application/json'}
    r = requests.post(url_login, data=json.dumps(payload), headers=headers).json()
    return (r['token'])
token =login("ID","PW")

class ConnectPage(GridLayout):
    oee = ObjectProperty(None)
    performance = ObjectProperty(None)
    quality = ObjectProperty(None)
    availability = ObjectProperty(None)
    sensorstandort = ObjectProperty(None)
    schicht = ObjectProperty(None)
    timestamp = ObjectProperty(None)
    alert = ObjectProperty(None)

    def oee_anzeige(self, *args):
        #Anfrage an Server senden
        url_report = 'URL/'
        payload_report = {}
        headers_report = {'content-type': 'application/json', 'Authorization': token}
        r_report = requests.get(url_report, data=json.dumps(payload_report), headers=headers_report)
        response = r_report.json()

        #Schicht, Sensorstandort und ggfs. Störgrund raussuchen
        x = 0
        for i in response['included']:
            if response['included'][x]['type'] == 'shift':
                schicht = response['included'][x]['attributes']['name']
            if response['included'][x]['type'] == 'location':
                sensorstandort = response['included'][x]['attributes']['name']
            if response['included'][x]['type'] == 'notification':

                timestamp = str(response['included'][x]['attributes']['inserted-at'])
                timestamp = timestamp[11:16] + ' Uhr'

                #self.timestamp.text = timestamp
                if response['included'][x]['attributes']['triggered-by'] == 'standstill':
                    self.alert.text = "Verfügbarkeitsverlust seit"
                elif sensorstandort == response['included'][x]['attributes']['triggered-by'] == 'slowdown':
                    self.alert.text = "Leistungsverlust seit"
            x +=1






        #oee Werte aus API ziehen
        oee = str(response['data']['attributes']['oee']) + " %"
        availability = str(response['data']['attributes']['availability']) + " %"
        performance =str(response['data']['attributes']['performance']) + " %"
        quality = str(response['data']['attributes']['quality']) + " %"




        #Labels definieren
        self.oee.text = oee
        self.availability.text = availability
        self.performance.text = performance
        self.quality.text = quality
        self.sensorstandort.text = sensorstandort
        self.schicht.text = schicht


    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.cols = 2  # used for our grid


class EpicApp(App):
    def build(self):
        t = ConnectPage()
        Clock.schedule_once(t.oee_anzeige, 2)
        Clock.schedule_interval(t.oee_anzeige, 90)
        return t



if __name__ == "__main__":
    EpicApp().run()



Epic.kv史诗.kv


<ConnectPage>:





    oee:oee
    availability: availability
    performance: performance
    quality: quality
    sensorstandort: sensorstandort
    schicht: schicht
    alert: alert
    timestamp: timestamp

    GridLayout:
        cols: 2


        Label:
            text: "wird geladen"
            id: sensorstandort
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text: "wird geladen"
            id: schicht
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text: "OEE"
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text: "wird geladen"
            id: oee
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]



        Label:
            text: "Verfügbarkeit"
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text: "Wird geladen"
            id: availability
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]



        Label:
            text: "Leistung"
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text: "Wird geladen"
            id: performance
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]


        Label:
            text: "Qualität"
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text: "Wird geladen"
            id: quality
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]


        Label:
            text:
            id: alert
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

        Label:
            text:
            id: timestamp
            text_size: self.width, None
            size_hint: 1, None
            height: self.texture_size[1]

Log from Buildozer Logcat:来自 Buildozer Logcat 的日志:

....
04-01 19:37:22.029 19854 19881 I python  :  Traceback (most recent call last):
04-01 19:37:22.030 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 97, in <module>
04-01 19:37:22.031 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run
04-01 19:37:22.032 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp
04-01 19:37:22.034 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop
04-01 19:37:22.035 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop
04-01 19:37:22.035 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle
04-01 19:37:22.036 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick
04-01 19:37:22.037 19854 19881 I python  :    File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
04-01 19:37:22.037 19854 19881 I python  :    File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
04-01 19:37:22.038 19854 19881 I python  :    File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
04-01 19:37:22.039 19854 19881 I python  :    File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
04-01 19:37:22.040 19854 19881 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:37:22.041 19854 19881 I python  :  AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:37:22.041 19854 19881 I python  : Python for android ended.
....
04-01 19:44:07.500 20768 20788 I python  :  Traceback (most recent call last):
04-01 19:44:07.501 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 97, in <module>
04-01 19:44:07.502 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run
04-01 19:44:07.503 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp
04-01 19:44:07.504 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop
04-01 19:44:07.504 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop
04-01 19:44:07.505 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle
04-01 19:44:07.505 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick
04-01 19:44:07.506 20768 20788 I python  :    File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
04-01 19:44:07.507 20768 20788 I python  :    File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
04-01 19:44:07.507 20768 20788 I python  :    File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
04-01 19:44:07.508 20768 20788 I python  :    File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
04-01 19:44:07.508 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:44:07.509 20768 20788 I python  :  AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:44:07.509 20768 20788 I python  : Python for android ended.
04-01 19:48:13.346 21723 21762 I python  : Initializing Python for Android
04-01 19:48:13.347 21723 21762 I python  : Setting additional env vars from p4a_env_vars.txt
04-01 19:48:13.347 21723 21762 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
04-01 19:48:13.347 21723 21762 I python  : /data/user/0/org.test.oeecloud/files/app
04-01 19:48:13.356 21723 21762 I python  : Preparing to initialize python
04-01 19:48:13.356 21723 21762 I python  : _python_bundle dir exists
04-01 19:48:13.356 21723 21762 I python  : calculated paths to be...
04-01 19:48:13.356 21723 21762 I python  : /data/user/0/org.test.oeecloud/files/app/_python_bundle/stdlib.zip:/data/user/0/org.test.oeecloud/files/app/_python_bundle/modules
04-01 19:48:13.380 21723 21762 I python  : set wchar paths...
04-01 19:48:13.420 21723 21762 I python  : Initialized python
04-01 19:48:13.420 21723 21762 I python  : AND: Init threads
04-01 19:48:13.421 21723 21762 I python  : testing python print redirection
04-01 19:48:13.422 21723 21762 I python  : Android path ['.', '/data/user/0/org.test.oeecloud/files/app/_python_bundle/stdlib.zip', '/data/user/0/org.test.oeecloud/files/app/...
'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
...
04-01 19:48:16.306 21723 21762 I python  : [INFO   ] [Base        ] Leaving application in progress...
04-01 19:48:16.307 21723 21762 I python  :  Traceback (most recent call last):
04-01 19:48:16.309 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 97, in <module>
04-01 19:48:16.311 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run
04-01 19:48:16.312 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp
04-01 19:48:16.312 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop
04-01 19:48:16.313 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop
04-01 19:48:16.314 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle
04-01 19:48:16.314 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick
04-01 19:48:16.315 21723 21762 I python  :    File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
04-01 19:48:16.315 21723 21762 I python  :    File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
04-01 19:48:16.315 21723 21762 I python  :    File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
04-01 19:48:16.316 21723 21762 I python  :    File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
04-01 19:48:16.316 21723 21762 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:48:16.317 21723 21762 I python  :  AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:48:16.317 21723 21762 I python  : Python for android ended.




This line of code in your .py files is throwing the error .py 文件中的这行代码抛出错误

 #self.timestamp.text = timestamp
                if response['included'][x]['attributes']['triggered-by'] == 'standstill':
                    self.alert.text = "Verfügbarkeitsverlust seit"
                elif sensorstandort == response['included'][x]['attributes']['triggered-by'] == 'slowdown':
                    self.alert.text = "Leistungsverlust seit"
            x +=1

I got this information by looking at the log you posted, which tells that there is an error in line 52 of main.py file我通过查看您发布的日志获得了此信息,该日志表明main.py文件的line 52存在错误

04-01 19:44:07.508 20768 20788 I python  :    File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:44:07.509 20768 20788 I python  :  AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:44:07.509 20768 20788 I python  : Python for android ended.

Hi thank you for your fast reply.您好,感谢您的快速回复。 I changed this things and now i get an new Error我改变了这些东西,现在我得到一个新的错误

attributeerror 'super' object has no attribute '__getattr__' kivy

i googled and edited my super.init to super(ConnectPage, self).__init__(**kwargs) but this error still occurs.我用谷歌搜索并将我的 super.init 编辑为super(ConnectPage, self).__init__(**kwargs)但这个错误仍然发生。

Do you have another tip for me?你对我还有什么建议吗? Thank you!谢谢! The Log says:日志说:

04-02 19:25:36.760 12173 12330 I python : Traceback (most recent call last): 04-02 19:25:36.762 12173 12330 I python : File "kivy/properties.pyx", line 860, in kivy.properties.ObservableDict. 04-02 19:25:36.760 12173 12330 I python:回溯(最近一次调用最后一次):04-02 19:25:36.762 12173 12330 I python:文件“kivy/properties.pyx”,第 86 行属性。 .ObservableDict。 getattr 04-02 19:25:36.764 12173 12330 I python : KeyError: 'availability' 04-02 19:25:36.765 12173 12330 I python : getattr 04-02 19:25:36.764 12173 12330 我蟒蛇:KeyError:'可用性' 04-02 19:25:36.765 12173 12330 我蟒蛇:
04-02 19:25:36.766 12173 12330 I python : During handling of the above exception, another exception occurred: 04-02 19:25:36.766 12173 12330 I python : 04-02 19:25:36.766 12173 12330 I python:在处理上述异常的过程中,发生了另一个异常:04-02 19:25:36.766 12173 12330 I python:
04-02 19:25:36.766 12173 12330 I python : Traceback (most recent call last): 04-02 19:25:36.767 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 96, in 04-02 19:25:36.768 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run 04-02 19:25:36.768 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp 04-02 19:25:36.769 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop 04-02 19:25:36.770 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop 04-02 19:25:36.771 12173 12330 I python : File "/home/ju 04-02 19:25:36.766 12173 12330 I python:回溯(最近一次调用最后一次):04-02 19:25:36.767 12173 12330 I python:文件“/home/julian/kivy/.buildozer/ main.py", line 96, in 04-02 19:25:36.768 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ oeecloud/kivy/app.py", line 855, in run 04-02 19:25:36.768 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build /python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp 04-02 19:25:36.769 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build- armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop 04-02 19:25:36.770 12173 12330 I python : File "/home/julian/kivy/ .buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop 04-02 19:25:36.771 12173 12330 I python :文件“/home/ju lian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle 04-02 19:25:36.773 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick 04-02 19:25:36.775 12173 12330 I python : File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events 04-02 19:25:36.777 12173 12330 I python : File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events 04-02 19:25:36.777 12173 12330 I python : File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events 04-02 19:25:36.778 12173 12330 I python : File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick 04-02 19:25:36.779 12173 12330 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 75, in oee_anzeige 04-02 19:25:36.779 12173 12330 I python : File "kivy/properties.pyx", line 863, in kivy.properties.ObservableDict. lian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle 04-02 19:25:36.773 12173 12330 I python :文件“/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py”,第591行,勾选04-02 19:25:36.775 12173 12330 I python :文件“kivy/_clock.pyx”,第 384 行,在 kivy._clock.CyClockBase._process_events 04-02 19:25:36.777 12173 12330 I python:文件“kivy/_clock.pyx4”,line41x4。在 kivy._clock.CyClockBase._process_events 04-02 19:25:36.777 12173 12330 我 python:文件“kivy/_clock.pyx”,第 412 行,在 kivy._clock.CyClockBase._process_events 09:16-2730:16-2730 12330 I python:文件“kivy/_clock.pyx”,第 167 行,在 kivy._clock.ClockEvent.tick 04-02 19:25:36.779 12173 12330 I python:文件“/home/julian/kivy/.buildozer/android /app/main.py", line 75, in oee_anzeige 04-02 19:25:36.779 12173 12330 I python : 文件 "kivy/properties.pyx", line 863, in kivy.properties.ObservableDict。 getattr 04-02 19:25:36.780 12173 12330 I python : AttributeError: 'super' object has no attribute ' getattr ' 04-02 19:25:36.780 12173 12330 I python : Python for android ended. getattr 04-02 19:25:36.780 12173 12330 I python: AttributeError: 'super' 对象没有属性 ' getattr ' 04-02 19:25:36.780 12173 12330 我 python:Android 的 Python 结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:&#39;NoneType&#39;对象没有属性&#39;text&#39;kivy - AttributeError: 'NoneType' object has no attribute 'text' kivy Python-Kivy AttributeError: 'NoneType' object 没有属性 'text' - Python-Kivy AttributeError: 'NoneType' object has no attribute 'text' Kivy AttributeError: 'NoneType' object 没有属性 'ids' - Kivy AttributeError: 'NoneType' object has no attribute 'ids' Kivy AttributeError: 'NoneType' object 没有属性 'current' - Kivy AttributeError: 'NoneType' object has no attribute 'current' Kivy Buildozer AttributeError:&#39;Context&#39;对象没有属性&#39;hostpython&#39; - Kivy Buildozer AttributeError: 'Context' object has no attribute 'hostpython' 'NoneType' object 在 Kivy 中没有属性 'text' - 'NoneType' object has no attribute 'text' in Kivy AttributeError:&#39;NoneType&#39;对象没有属性&#39;text&#39;-python - AttributeError: 'NoneType' object has no attribute 'text' - python Python:AttributeError:&#39;NoneType&#39;对象没有属性&#39;text&#39; - Python: AttributeError: 'NoneType' object has no attribute 'text' AttributeError: &#39;NoneType&#39; 对象没有属性 &#39;text&#39; - AttributeError: 'NoneType' object has no attribute 'text' Webscraping AttributeError:“ NoneType”对象没有属性“ text” - Webscraping AttributeError: 'NoneType' object has no attribute 'text'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM