-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathf_home.py
More file actions
95 lines (91 loc) · 3.52 KB
/
f_home.py
File metadata and controls
95 lines (91 loc) · 3.52 KB
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
89
90
91
92
93
94
95
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen
from kivymd.uix.dialog import MDDialog
from bidi.algorithm import get_display
from arabic_reshaper import reshape
from f_components import MDFlatButton
from important_variables import FONT_PATH
from b_manage_users import user_type, current_user_name
KV = """
<Home>:
MDFloatLayout:
MDPersianLabel:
label_text: app.language_dialogs["welcome"]
font_size: 25
halign: "center"
valign: "center"
pos_hint: {"x": .3, "y": .7}
size_hint: .4, .2
MDRectangleFlatIconButton:
button_text: app.language_dialogs["login"]
icon: "login"
pos_hint: {"x": .19, "y": .4}
size_hint: .3, .2
on_release: root.manager.current = "login"
MDRectangleFlatIconButton:
button_text: app.language_dialogs["register"]
icon: "account-plus"
pos_hint: {"x": .51, "y": .4}
size_hint: .3, .2
on_release: root.manager.current = "register_get_name"
MDRectangleFlatIconButton:
button_text: app.language_dialogs["delete_data"]
icon: "delete"
pos_hint: {"x": 0, "y": 0}
size_hint: .2, .1
on_release: root.delete_data()
MDRectangleFlatIconButton:
button_text: app.language_dialogs["set_webcam"]
icon: "camera"
pos_hint: {"x": .19, "y": .18}
size_hint: .3, .2
on_release: root.manager.current = "set_webcam"
MDRectangleFlatIconButton:
button_text: app.language_dialogs["statistics"]
icon: "chart-bar"
pos_hint: {"x": .51, "y": .18}
size_hint: .3, .2
on_release: root.manager.current = "statistics"
MDRectangleFlatIconButton:
button_text: app.language_dialogs["settings"]
icon: "cogs"
pos_hint: {'x': .75,'y': .9}
size_hint: .25, .1
on_release: root.manager.current = "settings"
MDIconButton:
icon: "information"
size_hint: .1, .1
pos_hint: {"x": .9, "y": 0}
on_release: root.manager.current = "information"
MDRectangleFlatIconButton:
button_text: app.language_dialogs["close_application"]
icon: "close"
pos_hint: {"x": 0, "y": .9}
size_hint: .2, .1
on_release: app.stop()
MDRectangleFlatIconButton:
button_text: app.language_dialogs["logout"]
icon: "logout"
pos_hint: {"x": 0, "y": .75}
size_hint: .2, .1
on_release: root.manager.current = "login_admins"
"""
class Home(MDScreen):
def delete_data(self):
if user_type(current_user_name()) == "creator":
self.manager.current = "ask_delete_data"
else:
persian_text = MDApp.get_running_app().language_dialogs["only_manager"]
text = "[font={}]{}[/font]".format(FONT_PATH,
get_display(reshape(persian_text)))
self.dialog = MDDialog(
title=text,
buttons=[
MDFlatButton(
text=get_display(reshape(MDApp.get_running_app().language_dialogs["i_got_it"])),
font_name=FONT_PATH,
on_release=lambda instance: self.dialog.dismiss()
)
]
)
self.dialog.open()