-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.py
55 lines (45 loc) · 1.38 KB
/
control.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
#!/usr/bin/python3.7
# UTF8
# Date: Thu 09 May 2019 14:40:35 CEST
# Author: Nicolas Flandrois
from sys import exit
from models import Product, Category
from view import View
def set_view(view, top_level=False):
res = view()
if res == "r":
if not top_level:
return None
elif res == "q":
exit()
else:
return res
def main():
"""Program's Main running function."""
while True:
res = set_view(View.main_view, True)
if res == 1:
while True:
cat_id = set_view(View.cats_view)
if cat_id:
while True:
prod_id = set_view(lambda: View.prods_view(cat_id))
if not prod_id:
break
while True:
set_view(lambda: View.sheet_view(prod_id))
set_view(lambda: View.substitution(prod_id))
break
if not cat_id:
break
elif res == 2:
set_view(View.sub_tbl)
res = set_view(lambda: View.menu("Question:", [
"Retour Menu Principal", "Quitter"]))
if res == 2:
exit()
if not res:
continue
if __name__ == '__main__':
print("Bienvenue dans ce programme.")
main()