-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
121 lines (94 loc) · 4.89 KB
/
Copy pathmain.py
File metadata and controls
121 lines (94 loc) · 4.89 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from function import identification_user, connected_user
from mongo_connection import data_mongo
class BoxIdentification(BoxLayout):
def build(self):
self.title = 'Identification'
self.orientation = "vertical"
self.black_space()
self.label_id()
self.black_space()
self.black_space()
self.username_label()
self.input_username_function()
self.black_space()
self.password_label()
self.input_password_function()
self.button_psw_forget()
self.black_space()
self.black_space()
self.black_space()
self.black_space()
self.button_identification()
self.black_space()
self.button_create_account()
self.black_space()
def label_id(self):
self.identification_message = Label(text="Identification", font_size=40, color=[0.59,0.239,0.89,1],
pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.identification_message)
# ----------------------------------------------------------- Username -----------------------------------------------------------#
def username_label(self):
self.label_username = Label(text="Enter your username", size_hint=(.2, .01), pos_hint={'x': 0.4, 'y': 0.7})
self.add_widget(self.label_username)
def input_username_function(self):
self.input_username = TextInput(text="", font_size=20, pos_hint={'x': .38, 'y': 0},
size_hint=(.24, .011), halign="center")
self.add_widget(self.input_username)
# ----------------------------------------------------------- Password -----------------------------------------------------------#
def password_label(self):
self.label_password = Label(text="Enter your password", size_hint=(.2, .01), pos_hint={'x': 0.4, 'y': 0.7})
self.add_widget(self.label_password)
def input_password_function(self):
self.input_password = TextInput(text="", font_size=20, pos_hint={'x': .38, 'y': 0},
size_hint=(.24, .011), halign="center")
self.add_widget(self.input_password)
# ----------------------------------------------------------- Space Graphic -----------------------------------------------------------#
def black_space(self):
self.black = Label(size_hint=(.4, .01))
self.add_widget(self.black)
# ----------------------------------------------------------- Button -----------------------------------------------------------#
def button_psw_forget(self):
self.confirmationButton = Button(text="Password forget?", size_hint=(.2, .01),
pos_hint={'x': 0.40, 'y': 0}, color=[0.59, 0.239, 0.89, 1])
self.confirmationButton.background_color = [0, 1, 0, 0]
self.confirmationButton.bind(on_press=self.password_forget)
self.add_widget(self.confirmationButton)
def button_identification(self):
self.confirmationButton = Button(text="Sign in", size_hint=(.2, .01),
pos_hint={'x': 0.40, 'y': 0})
self.confirmationButton.background_color = [0.59,0.239,0.89,1]
self.confirmationButton.bind(on_press=self.sign_in)
self.add_widget(self.confirmationButton)
def button_create_account(self):
self.create_account_button = Button(text="Create account?", size_hint=(.2, .01),
pos_hint={'x': 0.40, 'y': 0}, color=[0.59,0.239,0.89,1])
self.create_account_button.background_color = [0, 1, 0, 0]
self.create_account_button.bind(on_press=self.create_account)
self.add_widget(self.create_account_button)
# ----------------------------------------------------------- Function -----------------------------------------------------------#
def sign_in(self, instance):
"""
check is the username and the password are corrects, if is, show the message "connected"
:param instance:
:return: the type of connection (yes or not)
"""
user = self.input_username.text
password = self.input_password.text
self.identification_message.text = connected_user(identification_user(data_mongo(), user, password))
self.identification_message.color = [0, 1, 0, 1]
def password_forget(self):
pass
def create_account(self, instance):
pass
class Identification(App):
def build(self):
Layout = BoxIdentification()
Layout.build()
return Layout
if __name__ == '__main__':
Identification().run()