-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
249 lines (199 loc) · 6.87 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/usr/bin/env python3
# Author : Kourva
# Github : https://github.com/Kourva/SigNull
# This is test version!!
# Not completed and not optimized!!
# All imported Modules
# Plyer modules: for android functionality
from plyer import vibrator
from plyer import notification
from plyer.utils import platform
# Kivy modules: for the app
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.uix.gridlayout import GridLayout
from kivy.graphics import Color, Rectangle
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.screenmanager import Screen, ScreenManager
# KV config files
# All KV files used in this app
for files in [
"mainmenu.kv",
"console.kv",
"notification.kv",
"profile.kv",
"edit.kv",
]:
with open("Scripts/%s" % files, "r") as kv:
Builder.load_string(kv.read())
# ImageButton
# This is for clickable image buttons
class ImageButton(ButtonBehavior, Image):
def on_press(self):
pass
# MainMenu class
# This will handle MainMenu stuff
class MainMenu(Screen):
# Path to Assets
background = "Assets/background.jpg"
font = "Assets/font.ttf"
# Get data function
# This will get username and first-name and set it to user info
def get_data(self):
with open("Data/account", "r") as data:
lines = data.readlines()
try:
uname = lines[0].split(":")[1]
except IndexError:
uname = "Guest"
try:
fname = lines[1].split(":")[1]
except IndexError:
fname = "Guest"
self.manager.get_screen(
"Profile"
).ids.userinfo.text = f"{fname}\n[size=17][font=RobotoMono-Regular]@[color=#aaaaaa]{uname}[/color][/font]"
# Console menu class
# This will handle Console menu stuff
class Console(Screen):
# Path to Assets
background = "Assets/background.jpg"
font = "Assets/font.ttf"
# Get data function
# This will get username and first-name and set it to user info
def get_data(self):
with open("Data/account", "r") as data:
lines = data.readlines()
try:
uname = lines[0].split(":")[1]
except IndexError:
uname = "Guest"
try:
fname = lines[1].split(":")[1]
except IndexError:
fname = "Guest"
self.manager.get_screen(
"Profile"
).ids.userinfo.text = f"{fname}\n[size=17][font=RobotoMono-Regular]@[color=#aaaaaa]{uname}[/color][/font]"
# Notification menu class
# This will handle Notification menu stuff
class Notification(Screen):
# Path to Assets
background = "Assets/background.jpg"
font = "Assets/font.ttf"
# Get data function
# This will get username and first-name and set it to user info
def get_data(self):
with open("Data/account", "r") as data:
lines = data.readlines()
try:
uname = lines[0].split(":")[1]
except IndexError:
uname = "Guest"
try:
fname = lines[1].split(":")[1]
except IndexError:
fname = "Guest"
self.manager.get_screen(
"Profile"
).ids.userinfo.text = f"{fname}\n[size=17][font=RobotoMono-Regular]@[color=#aaaaaa]{uname}[/color][/font]"
# Profile menu class
# This will handle Profile menu stuff
class Profile(Screen):
# Path to Assets
background = "Assets/background.jpg"
font = "Assets/font.ttf"
# Load profile function
# This will load text inputs - in edit menu - to current info
def load_profile(self):
with open("Data/account", "r") as data:
lines = data.readlines()
try:
uname = lines[0].split(":")[1]
except IndexError:
uname = "Guest"
try:
fname = lines[1].split(":")[1]
except IndexError:
fname = "Guest"
self.manager.get_screen("Edit").ids.Username.text = "".join(uname)
self.manager.get_screen("Edit").ids.Firstname.text = "".join(fname)
# Edit menu class
# This will handle Edit menu stuff
class Edit(Screen):
# Path to Assets
background = "Assets/background.jpg"
font = "Assets/font.ttf"
# Get data function
# This will get username and first-name and set it to user info
def get_data(self):
with open("Data/account", "r") as data:
lines = data.readlines()
try:
uname = lines[0].split(":")[1]
except IndexError:
uname = "Guest"
try:
fname = lines[1].split(":")[1]
except IndexError:
fname = "Guest"
self.manager.get_screen(
"Profile"
).ids.userinfo.text = f"{fname}\n[size=17][font=RobotoMono-Regular]@[color=#aaaaaa]{uname}[/color][/font]"
# Save data function
# This will save the changes to username and first-name
def save_profile(self, Username, Firstname):
with open("Data/account", "w") as data:
data.write(f"uname:{Username.text.strip()}\nfname:{Firstname.text.strip()}")
self.manager.get_screen(
"Profile"
).ids.userinfo.text = f"{Firstname.text.strip()}\n[size=17][font=RobotoMono-Regular]@[color=#aaaaaa]{Username.text.strip()}[/color][/font]"
try:
title = "Success"
message = "Profile Updated..."
ticker = "New message"
kwargs = {
"title": title,
"message": message,
"ticker": ticker,
"toast": True,
"app_icon": "Data/notification.png",
}
notification.notify(**kwargs)
except:
pass
# Main class of the app
class SigNullApp(App):
# Build method
def build(self):
# Root screen
root = ScreenManager()
# Main menu screen
self.MainMenu = MainMenu(name="MainMenu")
root.add_widget(self.MainMenu)
# Console menu screen
self.Console = Console(name="Console")
root.add_widget(self.Console)
# Notification menu screen
self.Notification = Notification(name="Notification")
root.add_widget(self.Notification)
# Profile menu screen
self.Profile = Profile(name="Profile")
root.add_widget(self.Profile)
# Edit menu screen
self.Edit = Edit(name="Edit")
root.add_widget(self.Edit)
# Set current screen to main menu and return root
root.current = "MainMenu"
return root
# Run App
if __name__ == "__main__":
signull = SigNullApp()
signull.run()
# EOF