This commit is contained in:
2025-12-05 17:12:37 +01:00
parent 276044614d
commit 6f9b9c7605

View File

@@ -38,88 +38,6 @@ defaults = {
cur_config = {}
def menu(title, options):
"""
Display a menu and return selected value.
options must be list of (value, text) or text (auto-wrapped)
"""
if isinstance(options[0], str):
options = [(item, item) for item in options]
radio = RadioList(options)
kb = KeyBindings()
@kb.add("enter")
def _(event):
event.app.exit(result=radio.current_value)
@kb.add("q")
def _(event):
event.app.exit(result=None)
layout = Layout(HSplit([radio]))
app = Application(
layout=layout,
key_bindings=kb,
full_screen=True
)
return app.run()
# --------------------------
# MULTI-LEVEL MENU
# --------------------------
def main_menu():
while True:
choice = menu("Main Menu", [
"System",
"Network",
"Services",
"Exit"
])
if choice == "System":
system_menu()
elif choice == "Network":
network_menu()
elif choice == "Services":
services_menu()
elif choice == "Exit":
return
def system_menu():
choice = menu("System Menu", [
"Info",
"Reboot",
"Back"
])
print("SYSTEM →", choice)
def network_menu():
choice = menu("Network Menu", [
"Show IP",
"Restart Networking",
"Back"
])
print("NETWORK →", choice)
def services_menu():
choice = menu("Services", [
"Start Service",
"Stop Service",
"Status",
"Back"
])
print("SERVICES →", choice)
def load_config(defaults=defaults):
@@ -455,7 +373,6 @@ if __name__ == "__main__":
logger.warning("Killed manually %s, %s", sig, frame)
print("\nTerminated by user")
sys.exit(0)
main_menu()
signal.signal(signal.SIGINT, signal_handler)
os.system("cls" if os.name == "nt" else "clear")
if args.action is None: