-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_gui.py
More file actions
41 lines (33 loc) · 1.15 KB
/
main_gui.py
File metadata and controls
41 lines (33 loc) · 1.15 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
import os
import json
from main_package import Use
from main_package.gui.gui_utils import autentication2
from main_package.gui.gui_main_module import NoteManagerGui
from main_package.gui.gui_main_side_module import GuiMainSideMenus
ud_json = os.path.join('userdata', 'user.json')
tl_json = os.path.join('userdata', 'tl.json')
def load_json(path):
if os.path.exists(path) and os.path.getsize(path) > 0:
try:
with open(path, 'r') as f:
return json.load(f)
except json.JSONDecodeError:
return None
return None
# Load current logged user
ldata = load_json(tl_json)
# Load main user list
data = load_json(ud_json)
Use.ulist = data if data else []
os.system('cls' if os.name == 'nt' else 'clear')
# Start main app
if __name__ == '__main__':
app = NoteManagerGui()
if ldata and 'name' in ldata and 'psw' in ldata:
# load the profile menu
app.show_menu(app.side_menus.login_menu_frame)
autentication2(ldata['name'], ldata['psw'], app.show_profile_menu(ldata['name']))
else:
# load the main menu
app.show_menu(app.main_menu_frame)
app.mainloop()