From 9ff0d252275df96b034a55ef380374e7f24a4735 Mon Sep 17 00:00:00 2001 From: Calum Andrew Morrell Date: Mon, 19 May 2025 14:57:58 +0100 Subject: [PATCH] Added a method to display the menu, get & validate input, and return the input. --- dg_clt/menus.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dg_clt/menus.py b/dg_clt/menus.py index c593a9e..d32357f 100644 --- a/dg_clt/menus.py +++ b/dg_clt/menus.py @@ -1,4 +1,4 @@ -from screen import clear +from dg_clt.screen import clear class Menu: @@ -17,4 +17,10 @@ class Menu: print(f'{key}: {value}') else: print() - print(f'\n{self.selection}') + + def get_input(self): + while True: + self.display() + user_input = input(f'\n{self.selection}') + if user_input in self.menu_items.keys(): + return user_input