-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
66 lines (49 loc) · 1.55 KB
/
settings.py
File metadata and controls
66 lines (49 loc) · 1.55 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
import json
import os
CONFIG_FILE = 'config.json'
def load_config():
if not os.path.exists(CONFIG_FILE):
return {}
with open(CONFIG_FILE, 'r') as f:
return json.load(f)
def save_config(config):
with open(CONFIG_FILE, 'w') as f:
json.dump(config, f, indent=4)
def display_menu():
print("\nMenu:")
print("1. View Configuration")
print("2. Set Callsign")
print("3. Set Locator")
print("4. Set Favourite colour")
print("X. Exit")
def main():
config = load_config()
while True:
display_menu()
choice = input("Enter your choice: ")
if choice == '1':
print("\nCurrent Configuration:")
for key, value in config.items():
print(f"{key}: {value}")
elif choice == '2':
new_value = input("Enter Callsign: ")
config['callsign'] = new_value
save_config(config)
print("Callsign updated.")
elif choice == '3':
new_value = input("Enter Locator: ")
config['locator'] = new_value
save_config(config)
print("Locator updated.")
elif choice == '4':
new_value = input("Hi, I'm Buddy the Elf, what's your favourite colour?: ")
config['colour'] = new_value
save_config(config)
print("Colour updated.")
elif choice == 'x':
print("Exiting the menu.")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()