Code: Alles auswählen
import os
import _thread
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.clock import Clock
import json
setting_json = json.dumps(
[
{"type":"title",
"title":"Automatische Preis-Aktualisierung"
},
{"type":"bool",
"key":"AutoUpdate",
"section":"settings"
}
]
)
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.versSelected(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 verfuegbar"
on_press: app.UpdInf_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 guenstigem Preis"
Switch:
id:CheapNotSwitch
on_active: app.CheapNotSwitched(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 verfuegbar\\nwarte auf Updates und versuche es dann erneut"
# Button:
# size_hint: None, None
# height: 125
# width: 750
# text:"Auf Updates pruefen"
# 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 verfuegbar\\nwarte auf Updates und versuche es dann erneut"
Button:
size_hint: None, None
height: 125
width: 750
text:"Auf Updates pruefen"
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 verfuegbar\\nwarte auf Updates und versuche es dann erneut"
Button:
size_hint: None, None
height: 125
width: 750
text:"Auf Updates pruefen"
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 verfuegbar\\nwarte auf Updates und versuche es dann erneut"
Button:
size_hint: None, None
height: 125
width: 750
text:"Auf Updates pruefen"
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):
global c
c = 1
def CheapNotSwitched(self, instance, value):
if value == True:
notification.notify(message="Du erhälst ab jezt Benachrichtigungem bei günstigem Preis!\nDu kannst in den Einstellungen die Preise verändern bei denen du Benachrichtigugen erhalten willst!")
CheapNotify=open("/storage/emulated/0/TankstellenApp/CheapNotify.val", "w")
CheapNotify.write("True")
CheapNotify.close()
else:
CheapNotify=open("/storage/emulated/0/TankstellenApp/CheapNotify.val", "w")
CheapNotify.write("Fasle")
CheapNotify.close()
def on_start(self):
global c
if c == 1:
self.root.ids.refBUT.background_color=0,0,0,0
c = 0
else:
self.root.ids.refBUT.background_color=0,0,9,9
c = 1
if os.path.exists("/storage/emulated/0/TankstellenApp") == True:
pass
else:
urllib.request.urlretrieve("http://mscpiserver/TankstellenApp/Appfiles/files.zip", "/storage/emulated/0/files.zip")
ZipFile('/storage/emulated/0/files.zip').extractall("/storage/emulated/0/")
os.remove("/storage/emulated/0/files.zip")
global UpdateDA
checkVers=urllib.request.urlopen("http://mscpiserver/TankstellenApp/Versionen/latest.vers").read()
currentVers=open("/storage/emulated/0/TankstellenApp/vers.","r").read()
checkVers=str(checkVers)
currentVers=str(currentVers)
print(checkVers)
print(currentVers)
if checkVers.replace("b'","").replace("'","")==currentVers:
UpdateDA = False
else:
UpdateDA = True
if UpdateDA==True:
self.root.ids.UpdInf.pos_hint={'bottom':1}
else:
self.root.ids.UpdInf.pos_hint={'top':1}
getPrices=urllib.request.urlopen("http://mscpiserver/TankstellenApp/PreisErmitlung/OMVNBB.pri")
#getPrices=open("PreisErmitlung/OMVNBB.pri","r")
getPrices=str(getPrices.read())
getPrices=getPrices.split(";")
print(getPrices)
n = 0
for preis in getPrices:
n = n+1
if n == 1:
self.root.ids.sorte1.text=preis.replace("b'", "")
if n == 2:
self.root.ids.preis1.text=preis
if n == 3:
self.root.ids.sorte2.text=preis
if n == 4:
self.root.ids.preis2.text=preis
if n == 5:
self.root.ids.sorte3.text=preis
if n == 6:
self.root.ids.preis3.text=preis
if n == 7:
self.root.ids.sorte4.text=preis
if n == 8:
self.root.ids.preis4.text=preis
if n == 9:
self.root.ids.sorte5.text=preis
if n == 10:
self.root.ids.preis5.text=preis.replace("'", "")
break
#getPricesDVP=open("PreisErmitlung/DRIVERSINPB.pri","r")
getPricesDVP=urllib.request.urlopen("http://mscpiserver/TankstellenApp/PreisErmitlung/DRIVERSINPB.pri")
getPricesDVP=getPricesDVP.read()
getPricesDVP=str(getPricesDVP).split(";")
print(getPricesDVP)
n = 0
for preis in getPricesDVP:
n = n+1
if n == 1:
self.root.ids.sorte1DVP.text=preis.replace("b'", "")
if n == 2:
self.root.ids.preis1DVP.text=preis
if n == 3:
self.root.ids.sorte2DVP.text=preis
if n == 4:
self.root.ids.preis2DVP.text=preis
if n == 5:
self.root.ids.sorte3DVP.text=preis
if n == 6:
self.root.ids.preis3DVP.text=preis
if n == 7:
self.root.ids.sorte4DVP.text=preis
if n == 8:
self.root.ids.preis4DVP.text=preis
if n == 9:
self.root.ids.sorte5DVP.text=preis
if n == 10:
self.root.ids.preis5DVP.text=preis.replace("'", "")
break
#getPricesKGS=open("PreisErmitlung/SHELLKGB.pri","r")
getPricesKGS=urllib.request.urlopen("http://mscpiserver/TankstellenApp/PreisErmitlung/SHELLKGB.pri")
getPricesKGS=getPricesKGS.read()
getPricesKGS=str(getPricesKGS).split(";")
print(getPricesKGS)
n = 0
for preis in getPricesKGS:
n = n+1
if n == 1:
self.root.ids.sorte1KGS.text=preis.replace("b'", "")
if n == 2:
self.root.ids.preis1KGS.text=preis
if n == 3:
self.root.ids.sorte2KGS.text=preis
if n == 4:
self.root.ids.preis2KGS.text=preis
if n == 5:
self.root.ids.sorte3KGS.text=preis
if n == 6:
self.root.ids.preis3KGS.text=preis
if n == 7:
self.root.ids.sorte4KGS.text=preis
if n == 8:
self.root.ids.preis4KGS.text=preis
if n == 9:
self.root.ids.sorte5KGS.text=preis
if n == 10:
self.root.ids.preis5KGS.text=preis
if n == 11:
self.root.ids.sorte6KGS.text=preis
if n == 12:
self.root.ids.preis6KGS.text=preis.replace("'", "")
break
CheapNotify=open("/storage/emulated/0/TankstellenApp/CheapNotify.val", "r")
CheapNotify=CheapNotify.read()
if CheapNotify == "True":
pass
def UpdInf_gone(self, ActionPrevious):
self.root.ids.UpdInf.pos_hint={'top':1}
def versSelected(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": True})
def build_settings(self,settings):
settings.add_json_panel('Einstellungen', self.config, data=setting_json)
Clock.schedule_interval(on_start, 30)
# def AutoUpdateThread():
# _thread.start_new_thread(AutoUpdate, ())
# def AutoUpdate():
# while True:
# TankstellenApp().on_start()
# time.sleep(1)
# AutoUpdateThread()
#GAS=TankstellenApp()
#GAS.run()
print("run0")
TankstellenApp().run()