-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
80 lines (76 loc) · 2.33 KB
/
settings.py
File metadata and controls
80 lines (76 loc) · 2.33 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
#|==============================================================|#
# Made by IntSPstudio
# TEDASY
# Thank you for using this software!
# ID: 980001012
#|==============================================================|#
#SETTINGS
import tedasy as syst #SYSTEM
history: list = ["","",""]
#EXECUTE FUNCTION
def exec(input, value, mode:int):
output = []
output.append(input)
output.append(value)
output.append(mode)
syst.user_command(output)
if input !="f155":
if input != None:
history.append(input +": "+ str(value))
#MAIN LOOP
def show_menu(menu: dict, start_page :str="P01"):
#TA
continuity =1
menu_pa = syst.settings["cli"]["prefix"] #Row start mark
current_page = start_page
#MAIN LOOP
while continuity == 1:
#CLEAR SCREEN
exec("f155",0,5)
#HEADER
for i in history[-3:]:
print(i)
print(syst.settings["cli"]["topbar"])
print("")
#TB
page = menu.get(current_page, {})
title = page.get("Title", "Unknown")
print(menu_pa + title)
#MENU ROWS
rows = [(key, val) for key, val in page.items() if key.startswith("R")]
rows.sort()
if not rows:
current_page = start_page
for idx, (key, item) in enumerate(rows, start=1):
print(menu_pa + f"{idx}. {item['Title']}")
#USER CHOICE
try:
choice = int(input(menu_pa +"?. "))
if choice < 1 or choice > len(rows):
print("ERROR")
continue
except ValueError:
if current_page != start_page:
current_page = start_page
else:
print("ERROR")
continue
#USER INPUT
_, selected_item = rows[choice - 1]
if "Input" in selected_item:
syst_code = selected_item["Input"]
user_input = input(menu_pa + "Input: ")
exec(syst_code, user_input, 5)
#RETURN VALUE (PAGE OR FUNC)
_, selected_item = rows[choice - 1]
next_page = selected_item.get("Link")
if next_page and next_page in menu:
current_page = next_page
else:
exec(next_page,0,5)
if __name__ == "__main__":
#TA
syst.settings["runtype"] = 2
syst.start()
#TB
show_menu(syst.settings_pages, "P01")