-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
89 lines (59 loc) · 1.91 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
# -*- coding: utf-8 -*-
import kivy
from kivy.uix.popup import Popup
from kivy.uix.settings import Settings
kivy.require('1.0.5')
__version__ = '2.0'
from kivy.config import Config
# Samsung S4 : 1080x1920
Config.set('graphics', 'width', '450')
Config.set('graphics', 'height', '800')
## install & run with
# buildozer android debug deploy run
## see logs with
# adb logcat -s "python"
from kivy.app import App
from categories import CategoriesApp
from thes import ThesApp
from theDetail import TheDetailApp
#from multiprocessing import Pool
from threading import Thread
from datareader import JsonToDataBase
from customscreen import CustomScreenManager, CustomScreen
class AsyncLoader(Thread):
def __init__(self, callback, *largs, **kwargs):
super(AsyncLoader, self).__init__(*largs, **kwargs)
self.daemon = True
self.quit = False
self.callback = callback
def run(self):
d = JsonToDataBase()
d.loadData()
self.callback(loadingDone=True)
class Welcome(CustomScreen):
allCategories = {}
def startLoadingJson(self):
self.logLabel.text = "Chargement des données..."
loader = AsyncLoader(callback = self.callback_after_loading_json)
loader.start()
def callback_after_loading_json(self, loadingDone):
if loadingDone:
self.logLabel.text = "Chargement OK. (%s)" % len(JsonToDataBase().getAllCategories())
else:
self.logLabel.text = "Erreur lors du chargement."
def do_enter(self):
self.manager.go_next()
self.manager.current_screen.setCategories(JsonToDataBase().getAllCategories())
class WelcomeApp(App):
def build(self):
manager = CustomScreenManager()
# ajout de l'instance de page d'accueil
welcomeScreen = Welcome(name='Welcome')
manager.add_screen(welcomeScreen)
for app in [CategoriesApp(), ThesApp(), TheDetailApp()]:
app.load_kv()
manager.add_screen( app.build() )
return manager
if __name__ == '__main__':
WelcomeApp().run()