-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesign.kv
153 lines (147 loc) · 5.41 KB
/
design.kv
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<LoginScreen>: #create a screen
GridLayout: #widget for creating a grid
cols:1
GridLayout:#one column
cols:1
padding: 15, 15 #padding around
spacing: 20, 20 #space between widgetes
Label: #Create a label for the page
text: "User Login" #text for the label
font_size: '20sp' #font of 20 pixel (but need to pass a string = sp)
TextInput: #Create a input box for the user
id: username
hint_text:"Username" #text in the box
size_hint: 0.3, 0.5
TextInput:
id: password
hint_text:"Password"
password:True
size_hint: 0.3, 0.5
RelativeLayout: #to create a button with a size not depedent to the GridLayout
Button: #create a button
text:"Login" #text on the button
on_press: root.login(root.ids.username.text, root.ids.password.text)
size_hint: 0.3, 0.5
pos_hint:{'center_x':0.5, 'center_y':0.6}
Label:
id: login_wrong
text:""
GridLayout: #second half of the app as a 2 columns layot
cols:2
size_hint: 0.2, 0.2 #20% of the main GridLayout
padding: 10, 10
spacing: 10, 0
Button:
text:"Forgot Password?"
on_press: root.forget_password()
background_color: 1, 1, 1, 0
opacity:1 if self.state =='normal' else 0.3
color: 0.1, 0.7, 1, 1
Button:
text:"Sign Up"
on_press: root.sign_up() #root: refer to the class of the rule widgetes where it is placed. Any time the sign up button is pressed it calls the sign_up method in the .py file
background_color: 1, 1, 1, 0
opacity:1 if self.state =='normal' else 0.6
color: 0.1, 0.7, 1, 1
<SignUpScreen>: #create the sign up page
GridLayout:
cols: 1
padding: 20, 20
spacing: 20, 30
Label:
text:"Sign up!!"
font_size: '20sp'
TextInput:
id: username
hint_text: "Username"
size_hint: 0.3, 0.3
TextInput:
id: password
hint_text: "Password"
size_hint: 0.3, 0.3
Button:
text:"Sign Up"
on_press: root.add_user(root.ids.username.text, root.ids.password.text) #get back the text that the user entered in the text boxes
size_hint: 0.3, 0.4
<SignUpScreenSuccess>:
GridLayout:
cols:1
padding: 20, 0
spacing: 20, 0
Label:
text:"Sign up successfull!"
font_size: '20sp'
RelativeLayout:
Button:
text: "Login page"
on_press: root.login_back()
size_hint: 0.4, 0.2
pos_hint:{'center_x':0.5, 'center_y':0.6}
<ForgottenPassword>:
GridLayout:
cols:1
padding: 20, 0
spacing: 20, 0
Label:
text: "Insert Username:"
font_size: '20sp'
TextInput:
id:username_password
hint_text: "Username"
size_hint: 0.3, 0.5
RelativeLayout:
Button:
text:"Password:"
on_press: root.check_password(root.ids.username_password.text)
size_hint: 0.3, 0.5
pos_hint:{'center_x':0.5, 'center_y':0.6}
Label:
id:show_password
text:""
RelativeLayout:
Button:
text: "Login page"
on_press: root.forgot_password_back()
size_hint: 0.3, 0.5
pos_hint:{'center_x':0.5, 'center_y':0.6}
<LoginScreenSuccess>:
GridLayout:
cols:1
padding: 30, 40
spacing: 30, 40
RelativeLayout:
ImageButton:
source:'logout_hover.png' if self.hovered else 'logout_nothover.png'
on_press: root.log_out()
size_hint: 0.35, 0.35
pos_hint: {'center_x': 0.9, 'center_y': 0.7}
Label:
text:"How do you feel?"
font_size: '20pt'
TextInput:
id: feeling
hint_text:"Things to try: happy, sad, unloved...."
RelativeLayout:
Button:
text:"Go head!"
on_press: root.get_quote(root.ids.feeling.text)
size_hint: 0.3, 0.5
pos_hint:{'center_x':0.5, 'center_y':0.6}
ScrollView:
Label:
id: quote
text:""
text_size: self.width, None #resize the text with the width of the widget, the height is higher than the widget
size_hint_y: None #height is not as the Label
height: self.texture_size[1] #the label height is dinamic with the text. self.texture_size[0] will addapt the width with the text size
<RootWidget>: #Rule: invisible widget that take records of all the screen of the app
LoginScreen: #name for the screen
name: "login_screen"
SignUpScreen:
name: "sign_up_screen"
SignUpScreenSuccess:
name:"sign_up_screen_success"
ForgottenPassword:
name:"forget_password_screen"
LoginScreenSuccess:
name: "loging_screen_success"