Kivy AttributeError: 'NoneType' object has no attribute 'ids'

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Aber das ist doch komplett geraten. Du hast hier doch schonmal ein laufendes Beispiel von scheduling gehabt. Was soll denn bei deinem (mal abgesehen von dem Rechtschreibfehler) bei schedule_once rumkommen? Wenn ich dir sage "Mupfspace, mach was in 10 Sekunden" - was machst du dann? Nix. Ich habe dir naemlich nicht gesagt, WAS du in 10 Sekunden machen willst. Und du hast das hier auch nicht getan. Also kann die Antwort nur lauten 'nein, so nicht'.

Es ist schoen, dass du programmieren lernen willst. Aber du hast dir ein grossen, umfangreiches Problem gesucht, bei dem du mit raten versuchst, daran rum zu schrauben. Das wird leider nichts werden. Du hast ausserdem immer noch nicht deinen gesamten Code gezeigt, so dass man beurteilen koennte, was da wie ineinander greift. Woher die Dateien kommen, die du da auswertest zum Beispiel. Ich bin mir 100%ig sicher, dass man das besser machen kann, ganz ohne Dateien.
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

ich habe das deshalb mit schedule_once gemacht weil dann jedes mal beim aufrufen die zeit aktualisiert werden kann.

außerdem reicht doch once weil es ja praktisch die gleiche Fuktion aufruft in der schedule_once steht das heist es ist ja das gleiche wie interval blos halt mit ständig aktualisierender zeit.

...

Code: Alles auswählen


# -*- coding: iso-8859-1 -*-
import os
from io import BytesIO
from plyer import notification
import time
import urllib.request
import urllib
from zipfile import ZipFile
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.settings import SettingsWithSidebar
from kivy.uix.screenmanager import Screen
from kivy.uix.settings import SettingItem
from kivy.clock import Clock
import json
import _thread
import requests


STORAGE = "/storage/emulated/0"
APP_PATH = os.path.join(STORAGE, "TankstellenApp")
URL = "http://mscpiserver/TankstellenApp"


setting_json = json.dumps(
[
	{"type":"title",
	"title":"Automatische Preis-Aktualisierung"
	},
    {"type":"bool",
    "key":"AutoUpdate",
    "section":"settings",
    "title":"Automatische Preis-Aktualisierung durchf�hren",
    "desc":"Stelle die Automatische Preis-Aktualisierung An und Aus"
    },
	{"type":"numeric",
	"key":"AutoUpdateTime",
	"section":"settings",
	"title":"Zeitabstand zwischen den einzelnen Automatischen Preis-Aktualisierungen",
	"desc":"Setze den Zeitabstand zwischen den Automatischen Preis-Aktualisierungen fest"
	},
	{"type":"title",
	"title":"Push-Benachrichtigungen"
	},
	{"type":"bool",
	"key":"CheapNotify",
	"section":"settings",
	"title":"Pusch-Benachrichtigungen bei g�nstigen Preisen",
	"desc":"Stelle Push-Benachrichtigungen bei g�nstigen Preisen AN und Aus"


	}




]





)

g=Builder.load_string("""
#: import ListAdapter kivy.adapters.listadapter.ListAdapter
#: import ListItemButton kivy.uix.listview.ListItemButton


<ListItemButton>:
	selected_color: 0,0,5,5
	deselected_color: 0,0,0,0
	size: (100, 175)
	on_press: app.version_selected(self)
ScreenManager:
	Screen
		name:'main'
		TabbedPanel:
			tab_width: 375
			pos: 0,-100
			do_default_tab: False
			TabbedPanelItem:
				text:"OMV-Neubiberg"
				BoxLayout:
					padding: 120
					orientation:"vertical"
					pos_hint:{'top':1}
					size_hint: None, None
					height: 775
					spacing: "100"
					BoxLayout:
						spacing:"300"
						orientation:"horizontal"
					BoxLayout:
						spacing:"300"
						orientation: "horizontal"
						Label:
							id: sorte1
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis1
							height: 15
							size_hint: None, None
							text:"Preis: "
					BoxLayout:
						orientation: "horizontal"
						spacing:"300"
						Label:
							id: sorte2
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis2
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte3
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis3
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte4
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis4
							size_hint: None, None
							height: 15
							text: "Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte5
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis5
							size_hint: None, None
							height: 15
							text:"Preis:"
			TabbedPanelItem:
				text:"DriversIn-Putzbrunn"
				BoxLayout:
					padding: 120
					orientation:"vertical"
					pos_hint:{'top':1}
					size_hint: None, None
					height: 775
					spacing: "100"
					BoxLayout:
						spacing:"300"
						orientation:"horizontal"
					BoxLayout:
						spacing:"300"
						orientation: "horizontal"
						Label:
							id: sorte1DVP
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis1DVP
							height: 15
							size_hint: None, None
							text:"Preis: "
					BoxLayout:
						orientation: "horizontal"
						spacing:"300"
						Label:
							id: sorte2DVP
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis2DVP
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte3DVP
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis3DVP
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte4DVP
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis4DVP
							size_hint: None, None
							height: 15
							text: "Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte5DVP
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis5DVP
							size_hint: None, None
							height: 15
							text:"Preis:"
			TabbedPanelItem:
				width:300
				text:"Shell-Kehferloh/Grasbrunn"
				BoxLayout:
					padding: 120
					orientation:"vertical"
					pos_hint:{'top':1}
					size_hint: None, None
					height: 775
					spacing: "100"
					BoxLayout:
						spacing:"300"
						orientation:"horizontal"
					BoxLayout:
						spacing:"300"
						orientation: "horizontal"
						Label:
							id: sorte1KGS
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis1KGS
							height: 15
							size_hint: None, None
							text:"Preis: "
					BoxLayout:
						orientation: "horizontal"
						spacing:"300"
						Label:
							id: sorte2KGS
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis2KGS
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte3KGS
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis3KGS
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte4KGS
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis4KGS
							size_hint: None, None
							height: 15
							text: "Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte5KGS
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis5KGS
							size_hint: None, None
							height: 15
							text:"Preis:"
					BoxLayout:
						orientation:"horizontal"
						spacing:"300"
						Label:
							id: sorte6KGS
							size_hint: None, None
							height: 15
							text:"Benzinsorte:"
						Label:
							id: preis6KGS
							size_hint: None, None
							height: 15
							text:"Preis:"
				
            
        BoxLayout:
            padding: 350
            Button:
                id: refBUT
                background_color: 0,0,0,0
                size_hint: None, None
                height: 100
                width: 100
                on_press: app.on_start()
                on_release: app.on_start()
                Image:
                    source: "C.png"
                    y: self.parent.y + self.parent.height - 100
                    x: self.parent.x
                    size: 100, 100
                    allow_stretch: True
                
                    
                

		ActionBar:
			id: UpdInf
			background_color: 5,5,5,5
			pos_hint:{'bottom':1}
			ActionView:
				id: UpdInfView
				use_separator: True
				ActionPrevious:
					app_icon: "Cl.png"
					with_previous: False
					title:"Update verf�gbar"
					on_press: app.updateinfo_gone(self)
				ActionButton:
					icon:"Dow.png"
		ActionBar:
		    pos_hint: {'top':1}
		    ActionView:
		        use_separator: True
		        ActionPrevious:
		            title: 'Tankstellen App'
		            with_previous: False
		            #app_icon: 'Transparent.png'
		        ActionButton:
		        	#icon:'C.png'
		        ActionButton:
		            text: 'Einstellugen'
		            on_press: root.current='settings'
		        ActionButton:
		            text: 'Navigation'
		            on_press: root.current='NAV'
		        ActionButton:
		            text: 'Versionen'
		            on_press: root.current='Versions'
		        ActionGroup:
		            text: 'Hilfe'
		            ActionButton:
		                text: 'Anleitung'
		                on_press: root.current='guide'
		            ActionButton:
		                text: 'Quickstart'
		                on_press: root.current='QUICKSTART-Main'
		            ActionButton:
		        	    text: 'Support'
		        	    on_press: root.current='SUPPORT'
		        	    
	Screen:
		name:'settings'
		BoxLayout:
			orientaation:"vertical"
			BoxLayout:
				Label:
					text:"   Benachrichtigung erhalten\\n   bei g�nstigem Preis"
				Switch:
					id:CheapNotSwitch
					on_active: app.cheap_not_switched(self, self.active)
					on_active: app.open_settings()
					
					
#		BoxLayout:
#			orientation:"vertical"
#			Label:
#				text_size: self.size
#				halign: 'center'
#				valign: 'middle'
#				font_size: dp(25)
#				text:"Noch nicht verf�gbar\\nwarte auf Updates und versuche es dann erneut"
#			Button:
#				size_hint: None, None
#				height: 125
#				width: 750
#				text:"Auf Updates pr�fen"
#				on_press: root.current='Versions'
		ActionBar:
			pos_hint:{'top':1}
			ActionView:
				use_seperator: True
				ActionPrevious:
					title:"Einstellungen"
					with_previous: True
					app_icon:'S.png'
					on_press: root.current='main'
				
	Screen:
		name:'NAV'
		BoxLayout:
			orientation:"vertical"
			Label:
				text_size: self.size
				halign: 'center'
				valign: 'middle'
				font_size: dp(25)
				text:"Noch nicht verf�gbar\\nwarte auf Updates und versuche es dann erneut"
			Button:
				size_hint: None, None
				height: 125
				width: 750
				text:"Auf Updates pr�fen"
				on_press: root.current='Versions'
		ActionBar:
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					title:"Navigation"
					with_previous: True
					app_icon:'N.png'
					on_press: root.current='main'
					
	Screen:
		name:"SUPPORT"
		BoxLayout:
			orientation:"vertical"
			Label:
				text_size: self.size
				halign: 'center'
				valign: 'middle'
				font_size: dp(25)
				text:"Noch nicht verf�gbar\\nwarte auf Updates und versuche es dann erneut"
			Button:
				size_hint: None, None
				height: 125
				width: 750
				text:"Auf Updates pr�fen"
				on_press: root.current='Versions'
		ActionBar:
			pos_hint:{'top':1}
			ActionView:
				use_seperator: True
				ActionPrevious:
					title:"Support"
					with_previous: True
					app_icon:"Su.png"
					on_press: root.current="main"
	Screen:
		name:"Versions"
		BoxLayout:
			orientation:"vertical"
			Label:
				size_hint: None, None
				pos_hint:{'top':1}
				text:""
			BoxLayout:
				orientation:"horizontal"
				Button:
					text:"Info"
				Button:
					text:"Instalieren"
			ListView:
				adapter: ListAdapter(data=['foo', 'bar', 'baz'], cls=ListItemButton)
				size_hint: None, None
				width: 725
				height: 1100
		ActionBar:
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					title:"Versionen"
					app_icon:"V.png"
					with_previous: True
					on_press: root.current='main'
					
	Screen:
		name:"guide"
		BoxLayout:
			orientation:"vertical"
			Label:
				text_size: self.size
				halign: 'center'
				valign: 'middle'
				font_size: dp(25)
				text:"Noch nicht verf�gbar\\nwarte auf Updates und versuche es dann erneut"
			Button:
				size_hint: None, None
				height: 125
				width: 750
				text:"Auf Updates pr�fen"
				on_press: root.current='Versions'
		ActionBar:
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					title:"Anleitung"
					app_icon:"I.png"
					with_previous: True
					on_press: root.current='main'
					
	Screen:
		name:'QUICKSTART-Main'
		BoxLayout:
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					app_icon:"Transparent.png"
					with_previous: False
				ActionButton:
					icon:"Cl.png"	
					on_press: root.current='main'
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'Bottom':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					with_previous: False
					app_icon:"NBa.png"
					ActionButton:
						icon:"Cg.gif"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Ne.png"
						on_press: root.current='QUICKSTART-s2'
	Screen:
		name:'QUICKSTART-s2'
		BoxLayout:
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					app_icon:"Transparent.png"
					with_previous: False
				ActionButton:
					icon:"Cl.png"	
					on_press: root.current='main'
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'Bottom':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					with_previous: False
					app_icon:"Ba.png"
					on_press: root.current='QUICKSTART-Main'
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cg.gif"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Ne.png"
						on_press: root.current='QUICKSTART-s3'
	Screen:
		name:'QUICKSTART-s3'
		BoxLayout:
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					app_icon:"Transparent.png"
					with_previous: False
				ActionButton:
					icon:"Cl.png"	
					on_press: root.current='main'
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'Bottom':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					with_previous: False
					app_icon:"Ba.png"
					on_press: root.current='QUICKSTART-s2'
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cg.gif"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Ne.png"
						on_press: root.current="QUICKSTART-s4"
	Screen:
		name:'QUICKSTART-s4'
		BoxLayout:
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					app_icon:"Transparent.png"
					with_previous: False
				ActionButton:
					icon:"Cl.png"	
					on_press: root.current='main'
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'Bottom':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					with_previous: False
					app_icon:"Ba.png"
					on_press: root.current='QUICKSTART-s3'
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cg.gif"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Ne.png"
						on_press: root.current="QUICKSTART-s5"

	Screen:
		name:'QUICKSTART-s5'
		BoxLayout:
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'top':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					app_icon:"Transparent.png"
					with_previous: False
				ActionButton:
					icon:"Cl.png"	
					on_press: root.current='main'
		ActionBar:
			background_color: 0,0,0,0
			pos_hint:{'Bottom':1}
			ActionView:
				use_separator: True
				ActionPrevious:
					with_previous: False
					app_icon:"Ba.png"
					on_press: root.current='QUICKSTART-s4'
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cw.png"
					ActionButton:
						icon:"Cg.gif"
					ActionButton:
						icon:"NNe.png"
	    	
""")



class TankstellenApp(App):
    y=0
    def __init__(self):
	    super().__init__()
	    self.blink = True
	    self.update = False

    def cheap_not_switched(self, instance, value):
        if value:
        	notification.notify(message="Du erh�lst ab jetzt Benachrichtigungem bei g�nstigem Preis!")
        
    

    
    @staticmethod
    def download_files():
        if not os.path.exists(APP_PATH):
            with urllib.request.urlopen(URL + "/Appfiles/files.zip") as response:
                data = BytesIO(response.read())
            with ZipFile(data) as files:
                files.extractall(STORAGE)
                

    def check_version(self):
        with urllib.request.urlopen(URL + "/Versionen/latest.vers") as response:
            version = response.read().decode(response.headers.get_content_charset() or "ASCII")
        with open(os.path.join(APP_PATH, "vers")) as data:
            current_version = data.read()
        self.update = version != current_version


    def update_prices(self, url, labels):
        with urllib.request.urlopen(URL + url) as response:
            prices = response.read().decode(response.headers.get_content_charset() or "ASCII")
            print(prices)
        for label, price in zip(labels, prices.split(';')):
            label.text = price

   
    def update_all(self, dt):
        self.download_files()
        self.check_version()
        self.root.ids.UpdInf.pos_hint = {'bottom' if self.update else 'top': 1}
        ids = self.root.ids
        self.update_prices("/PreisErmitlung/OMVNBB.pri", [
            ids.sorte1, ids.preis1,
            ids.sorte2, ids.preis2,
            ids.sorte3, ids.preis3,
            ids.sorte4, ids.preis4,
            ids.sorte5, ids.preis5,
        ])
        self.update_prices("/PreisErmitlung/DRIVERSINPB.pri", [
            ids.sorte1DVP, ids.preis1DVP,
            ids.sorte2DVP, ids.preis2DVP,
            ids.sorte3DVP, ids.preis3DVP,
            ids.sorte4DVP, ids.preis4DVP,
            ids.sorte5DVP, ids.preis5DVP,
        ])
        self.update_prices("/PreisErmitlung/SHELLKGB.pri", [
            ids.sorte1KGS, ids.preis1KGS,
            ids.sorte2KGS, ids.preis2KGS,
            ids.sorte3KGS, ids.preis3KGS,
            ids.sorte4KGS, ids.preis4KGS,
            ids.sorte5KGS, ids.preis5KGS,
            ids.sorte6KGS, ids.preis6KGS,
        ])

    def on_start(self):
        self.root.ids.refBUT.background_color=(0,0,0,0) if self.blink else (0,0,9,9)
        self.blink = not self.blink
        self.update_all("*")
       
      
    
    def updateinfo_gone(self, ActionPrevious):
        self.root.ids.UpdInf.pos_hint={'top':1}

    def version_selected(self, ListItemButton):
        print("^")

    def build(self):
	    self.settings_cls = SettingsWithSidebar
	    self.use_kivy_settings= False
	    return g



    def build_config(self, config):
	    self.config.setdefaults('settings',{"AutoUpdate": 1, "AutoUpdateTime": 30, "CheapNotify": 0})

    def build_settings(self,settings):
	    settings.add_json_panel('Einstellungen', self.config, data=setting_json)

    


                

    def auto_update(self, dt):
        #while True:
        with open(os.path.join(APP_PATH, "AutoUpdate.val"), "r") as auto_update_bool:
            auto_update_bool = auto_update_bool.read()
        with open(os.path.join(APP_PATH, "AutoUpdateTime.val"),"r") as auto_update_time:
            auto_update_time = auto_update_time.read()
        if auto_update_bool == "1":
            self.update_all("*")
        else:
            pass
        auto_update_time = (int(auto_update_time)*60)
        Clock.schedule_once(self.auto_update, auto_update_time)
        #time.sleep(int(auto_update_time)*60)            
    
    
            

   
            
    def on_config_change(self, config, section, key, value):
        if key == "AutoUpdate":
            with open(os.path.join(APP_PATH, "AutoUpdate.val"),"w") as auto_update_bool:
                auto_update_bool.write(value)
        if key == "CheapNotify":
           with open(os.path.join(APP_PATH , "CheapNotify.val"),"w") as cheap_notify_bool:
               cheap_notify_bool.write(value)
        if key == "AutoUpdateTime":
            with open (os.path.join(APP_PATH, "AutoUpdateTime.val"),"w") as auto_update_time:
                auto_update_time.write(value)
        
        
        

    


    


def main():
	app = TankstellenApp()
	app.download_files()
	#_thread.start_new_thread(app.auto_update, ())
	Clock.schedule_once(app.auto_update, 0)
	app.run()

if __name__ == '__main__':
    main()

...
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Ist dass dann das gleiche Problem wie bei dem thread und dem Beispiel mit der Straße?
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Es ist schon besser. Allerdings hast du natürlich das Problem, dass dein autoupdate nie wieder beginnt. Ich würde also schedule_interval machen, aber dann in auto_update einfach prüfen, ob man was machen soll. Wenn nicht, einfach nichts machen.

Damit Sparst du dir die Komplexität das an und aus zu schalten. Etc.
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Aber dann kann man die Zeit nicht verändern
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Ist das wichtig? Alle wieviele Sekunden updated denn so eine Tankstelle ihre Preise?
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

__deets__ hat geschrieben: Samstag 9. Februar 2019, 10:55 Ist das wichtig? Alle wieviele Sekunden updated denn so eine Tankstelle ihre Preise?
2-3 mal am Tag?
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Und da reicht alle halbe Stunde gucken nicht? Das muss fein granular einstellbar sein? Und warum schaltet man das überhaupt aus? Will man keine aktuellen Zahlen? Wenn man aktuelle Zahlen will, warum fragst du dann nicht ab, wenn der Benutzer interagiert?
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Aber der Fehler das es nicht immer klappt kommt jezt nicht mehr oder?
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Oh...
leider habe ich gerade bemerkt dass das ursprüngliche Thema
Kivy AttributeError: 'NoneType' object has no attribute 'ids'
doch noch nicht so ganz durch

Code: Alles auswählen

def __init__(self):
	super().__init__()
gegessen ist...

ich habe ein Popup mit einem Label erställt auf dem ein besonders günstiger Preis angezeigt werden soll.
kv code:

Code: Alles auswählen

#:import Factory kivy.factory.Factory

<CheapPricePopup@Popup>:
    on_open: root.test()
    title:"Es gibt derzeit günstiges Benzin"
    size_hint: None,None
    size: 500,500
    auto_dismiss: False
	BoxLayout:
		orientation: "vertical"
		ScrollView:
            		size_hint: None,None
           		size: 475,400
			BoxLayout:
				orientation: "vertical"
				size_hint: None,None
				height:1450
				BoxLayout:
					Label:
                    				id:lalalal
                      		         	text:"Preis:/Tankstelle"
                      		         Label:
                        			text:"Benzinsorte:/Tankstelle:"




            
                   
		BoxLayout:
			#orientation: "vertical"
			Button:
				size_hint_y: None
				height: 100
				text: "Okay"
				on_release: root.dismiss()
python code:

Code: Alles auswählen


class CheapPricePopup(Popup):
    def __init__(self):
	    super().__init__()
    def test(self):
        print("test")
error:

Code: Alles auswählen

[INFO   ] [Logger      ] Record log in C:\Users\MupfSpace\.kivy\logs\kivy_19-02-09_51.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.5.0 - Build 22.20.16.4771'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 620'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 5
[INFO   ] [GL          ] Shading version <b'4.50 - Build 22.20.16.4771'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Text        ] Provider: sdl2
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\uix\listview.py line 845.Called from C:\Python37\lib\site-packages\kivy\lang\builder.py line 582 by _apply_rule().
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\adapters\simplelistadapter.py line 49.Called from C:\Python37\lib\site-packages\kivy\uix\listview.py line 859 by __init__().
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\adapters\adapter.py line 111.Called from C:\Python37\lib\site-packages\kivy\adapters\simplelistadapter.py line 55 by __init__().
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\uix\abstractview.py line 42.Called from C:\Python37\lib\site-packages\kivy\uix\listview.py line 865 by __init__().
[INFO   ] [GL          ] NPOT texture support is available
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\adapters\listadapter.py line 185.Called from <string> line 634 by <module>().
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\adapters\adapter.py line 111.Called from C:\Python37\lib\site-packages\kivy\adapters\listadapter.py line 186 by __init__().
Diesel;1.189;Super E10;1.229;Super E5;1.249;MaxxMotion: Super 100;1.429;MaxxMotion: Diesel;1.369
Autogas LPG;0.659;Diesel;1.269;Super E10;1.299;Super E5;1.319;SuperPlus;1.399
Diesel;1.199;Super E10;1.229;Super E5;1.269;V-Power: Racing;1.459;V-Power: Diesel;1.389;LKW Diesel;1.199
[INFO   ] [Base        ] Start application main loop
[WARNING] [Call to deprecated function __init__ in C]\Python37\lib\site-packages\kivy\uix\selectableview.py line 38.Called from C:\Python37\lib\site-packages\kivy\uix\listview.py line 593 by __init__().
[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "c:\Users\MupfSpace\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\ptvsd_launcher.py", line 45, in <module>
     main(ptvsdArgs)
   File "c:\Users\MupfSpace\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\__main__.py", line 348, in main
     run()
   File "c:\Users\MupfSpace\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\__main__.py", line 253, in run_file
     runpy.run_path(target, run_name='__main__')
   File "C:\Python37\lib\runpy.py", line 263, in run_path
     pkg_name=pkg_name, script_name=fname)
   File "C:\Python37\lib\runpy.py", line 96, in _run_module_code
     mod_name, mod_spec, pkg_name, script_name)
   File "C:\Python37\lib\runpy.py", line 85, in _run_code
     exec(code, run_globals)
   File "c:\Users\MupfSpace\Desktop\App test1\mainpy3v7.0.py", line 1101, in <module>
     main()
   File "c:\Users\MupfSpace\Desktop\App test1\mainpy3v7.0.py", line 1098, in main
     app.run()
   File "C:\Python37\lib\site-packages\kivy\app.py", line 826, in run
     runTouchApp()
   File "C:\Python37\lib\site-packages\kivy\base.py", line 502, in runTouchApp
     EventLoop.window.mainloop()
   File "C:\Python37\lib\site-packages\kivy\core\window\window_sdl2.py", line 727, in mainloop
     self._mainloop()
   File "C:\Python37\lib\site-packages\kivy\core\window\window_sdl2.py", line 460, in _mainloop
     EventLoop.idle()
   File "C:\Python37\lib\site-packages\kivy\base.py", line 337, in idle
     Clock.tick()
   File "C:\Python37\lib\site-packages\kivy\clock.py", line 581, in tick
     self._process_events()
   File "kivy\_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
   File "kivy\_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
   File "kivy\_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
   File "kivy\_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
   File "C:\Python37\lib\site-packages\kivy\animation.py", line 352, in _update
     self.stop(widget)
   File "C:\Python37\lib\site-packages\kivy\animation.py", line 217, in stop
     self.dispatch('on_complete', widget)
   File "kivy\_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
   File "C:\Python37\lib\site-packages\kivy\uix\modalview.py", line 195, in <lambda>
     a.bind(on_complete=lambda *x: self.dispatch('on_open'))
   File "kivy\_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1098, in kivy._event.EventObservers._dispatch
   File "C:\Python37\lib\site-packages\kivy\lang\builder.py", line 64, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "<string>", line 7, in <module>
   File "kivy\weakproxy.pyx", line 30, in kivy.weakproxy.WeakProxy.__getattr__
 AttributeError: 'CheapPricePopup' object has no attribute 'test'
womit wir wieder beim ursprünglichen Thema angekomne wären...
was kann ich dagegen tun?
Benutzeravatar
__blackjack__
User
Beiträge: 13004
Registriert: Samstag 2. Juni 2018, 10:21
Wohnort: 127.0.0.1
Kontaktdaten:

@MupfSpace: Das `None` keine Attribute hat ist irgendwie nicht das gleiche Thema wie das `CheapPricePopup` ein Attribut nicht hat.

Lass mal das ``@Popup`` in der kv-Datei weg. Die `__init__()` macht so auch keinen Sinn – wenn man da eh nur die von der Basisklasse aufruft, kann man sie auch weglassen.

Falls das nicht hilft, wäre ein minimales, lauffähiges Beispiel nett, welches das Problem demonstriert, damit man das mal ausprobieren kann.
“Most people find the concept of programming obvious, but the doing impossible.” — Alan J. Perlis
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

@__blackjack__
Danke das mit dem @popup weglassen funktioniert
@__deets__
__deets__ hat geschrieben: Donnerstag 7. Februar 2019, 19:00ich bin mir 100%ig sicher, dass man das besser machen kann, ganz ohne Dateien.
Ich hab das jezt mit einer einzigen .ini Datei und configparser und dem selbstgeschriebenen (aber unfertigen ) Modul iniparser gemacht.

Bist du jezt stolz auf mich? :P
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Stolz ist ein bisschen uebertrieben. Aber wenn du Fortschritte machst, schoen fuer dich!
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Ich versuche jezt schon seit längerer Zeit etwas an der Benachrichtigung zu verändern.

Und zwar möchte ich das wenn man auf die Benachrichtigung clickt etwas passiert.
Mit plyer ist das anscheinend nicht möglich.
Ich habe im Internet nachgesehen und etwas über pyjnius gefunden davon aber nichts kapiert.
Ich habe außerdem auf einer github seite:

https://github.com/Bakterija/android-no ... on-buttons

Etwas über noti_builder Notification_Builder gefunden verstehe aber nicht was mit: Kopiere den noti_builder Ordner in den /Service Ordner.
Welche Service Ordner ist damit gemeint.

Oder gibt es noch andere Möglichkeiten Benachrichtigungen auf android zu erstellen?
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Wenn es keine andere Möglichkeit gibt wie funktioniert das dann mit pyjnius und / oder noti_builder
Im Internet finde ich zwar immer wieder Sachen dazu aber meist sind das immer Dinge die nicht funktionieren.
Was kann ich tun?
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

Bitte
Gebt mir wenigstens einen Tip...
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Ich benutze kein Android. Ich kann das also auch nicht ausprobieren. Das von dir genannte Framework hat eine Beispielanwendung. Probier die zum laufen zu bringen Und frag beim Autor des Tools nach, wenn du damit Probleme hast. Dann gewinnst du hoffentlich Erkenntnisse, wie das funktioniert.
MupfSpace
User
Beiträge: 169
Registriert: Montag 25. Dezember 2017, 20:26

ich habe es nicht geschafft die Beispiel Anwendung zum laufen zu bringen
es könnte daran liegen dass "noti_builder" pyjnius verwendet:
Erste zeile von noti_builder:

Code: Alles auswählen

from jnius import autoclass, detach
ich habe es verucht zu installieren aber bekomme immer diesen fehler

Code: Alles auswählen

Collecting pyjnius
  Using cached https://files.pythonhosted.org/packages/b6/57/c90acf31322e6417f06c90410dbfcb149633a6006b7efbf99dfebe177c1f/pyjnius-1.2.0.tar.gz
Requirement already satisfied: six>=1.7.0 in c:\users\mupfspace\appdata\roaming\python\python37\site-packages (from pyjnius) (1.12.0)
Requirement already satisfied: cython in c:\python37\lib\site-packages (from pyjnius) (0.29.6)
Building wheels for collected packages: pyjnius
  Building wheel for pyjnius (setup.py) ... error
  Complete output from command c:\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MUPFSP~1\\AppData\\Local\\Temp\\pip-install-6x0l7_5g\\pyjnius\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\MUPFSP~1\AppData\Local\Temp\pip-wheel-p37h30j9 --python-tag cp37:
  WARNING: Not able to assign machine() = AMD64 to a cpu value!
           Using cpu = 'i386' instead!
  JDK_HOME: C:\Program Files\Java\jdk-11.0.2\bin

  JRE_HOME: None

  warning: [options] bootstrap class path not set in conjunction with -source 6
  warning: [options] source value 6 is obsolete and will be removed in a future release
  warning: [options] target value 1.6 is obsolete and will be removed in a future release
  warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
  4 warnings
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.7
  copying jnius_config.py -> build\lib.win32-3.7
  creating build\lib.win32-3.7\jnius
  copying jnius\reflect.py -> build\lib.win32-3.7\jnius
  copying jnius\signatures.py -> build\lib.win32-3.7\jnius
  copying jnius\__init__.py -> build\lib.win32-3.7\jnius
  creating build\lib.win32-3.7\jnius\src
  creating build\lib.win32-3.7\jnius\src\org
  creating build\lib.win32-3.7\jnius\src\org\jnius
  copying jnius\src\org\jnius\NativeInvocationHandler.class -> build\lib.win32-3.7\jnius\src\org\jnius
  copying jnius\src\org\jnius\NativeInvocationHandler.java -> build\lib.win32-3.7\jnius\src\org\jnius
  running build_ext
  cythoning jnius\jnius.pyx to jnius\jnius.c
  c:\python37\lib\site-packages\Cython\Compiler\Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\MUPFSP~1\AppData\Local\Temp\pip-install-6x0l7_5g\pyjnius\jnius\jnius.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'jnius' extension
  creating build\temp.win32-3.7
  creating build\temp.win32-3.7\Release
  creating build\temp.win32-3.7\Release\jnius
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Java\jdk-11.0.2\bin\include" "-IC:\Program Files\Java\jdk-11.0.2\bin\include\win32" -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcjnius\jnius.c /Fobuild\temp.win32-3.7\Release\jnius\jnius.obj
  jnius.c
  jnius\jnius.c(593): fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "jni.h": No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for pyjnius
  Running setup.py clean for pyjnius
Failed to build pyjnius
Installing collected packages: pyjnius
  Running setup.py install for pyjnius ... error
    Complete output from command c:\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MUPFSP~1\\AppData\\Local\\Temp\\pip-install-6x0l7_5g\\pyjnius\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\MUPFSP~1\AppData\Local\Temp\pip-record-438q2p2q\install-record.txt --single-version-externally-managed --compile:
    WARNING: Not able to assign machine() = AMD64 to a cpu value!
             Using cpu = 'i386' instead!
    JDK_HOME: C:\Program Files\Java\jdk-11.0.2\bin

    JRE_HOME: None

    warning: [options] bootstrap class path not set in conjunction with -source 6
    warning: [options] source value 6 is obsolete and will be removed in a future release
    warning: [options] target value 1.6 is obsolete and will be removed in a future release
    warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    4 warnings
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying jnius_config.py -> build\lib.win32-3.7
    creating build\lib.win32-3.7\jnius
    copying jnius\reflect.py -> build\lib.win32-3.7\jnius
    copying jnius\signatures.py -> build\lib.win32-3.7\jnius
    copying jnius\__init__.py -> build\lib.win32-3.7\jnius
    creating build\lib.win32-3.7\jnius\src
    creating build\lib.win32-3.7\jnius\src\org
    creating build\lib.win32-3.7\jnius\src\org\jnius
    copying jnius\src\org\jnius\NativeInvocationHandler.class -> build\lib.win32-3.7\jnius\src\org\jnius
    copying jnius\src\org\jnius\NativeInvocationHandler.java -> build\lib.win32-3.7\jnius\src\org\jnius
    running build_ext
    skipping 'jnius\jnius.c' Cython extension (up-to-date)
    building 'jnius' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\jnius
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Java\jdk-11.0.2\bin\include" "-IC:\Program Files\Java\jdk-11.0.2\bin\include\win32" -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcjnius\jnius.c /Fobuild\temp.win32-3.7\Release\jnius\jnius.obj
    jnius.c
    jnius\jnius.c(593): fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "jni.h": No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MUPFSP~1\\AppData\\Local\\Temp\\pip-install-6x0l7_5g\\pyjnius\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\MUPFSP~1\AppData\Local\Temp\pip-record-438q2p2q\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\MUPFSP~1\AppData\Local\Temp\pip-install-6x0l7_5g\pyjnius\
__deets__
User
Beiträge: 14493
Registriert: Mittwoch 14. Oktober 2015, 14:29

Kenne mich mit Python-auf-Android nicht aus, aber dein Android hat garantiert kein x86er CPU. Kann es sein, dass du das fuer das normale System und dein Python da installierst? Das geht dann wohl in die Hose.

Aber wie gesagt, da kenne ich mich nicht aus. Ich benutze iOS.
Tholo
User
Beiträge: 177
Registriert: Sonntag 7. Januar 2018, 20:36

@ Deets
Das Überascht mich jetzt :P
Ich hätte vermutet du bist der Root-Android-Kali-Linux-Lineageos Smartphone User schlechthin und kein schnödes "Apfel aus der Box"
:lol:

@MS

Schau dir mal diese Gruppe an
https://groups.google.com/forum/embed/# ... kivy-users da sind viele Infos und Probleme bereits beschrieben. Vielleicht findest du da etwas.
AUßER dein Fehler! Ich würde vermuten du nutzt eine IDE auf Windows und so wie es eben aussieht wird dieser Code auch auf Win ausgeführ und nicht auf dem Handy. Interpreter richtig gesetzt?
Antworten