initial build

This commit is contained in:
2022-10-02 17:12:41 +02:00
parent ef8a139e71
commit d6467b2a8f
16 changed files with 632 additions and 0 deletions

34
ui/selection_menu.py Normal file
View File

@@ -0,0 +1,34 @@
class SelectionMenu:
def __init__(self, title):
self.title = title
self.options = []
def add_option(self, title, callback):
self.options.append({"title": title, "callback": callback})
return self
def display(self):
print("")
print(f"/--[ {self.title} ]----------------------------")
for i in range(len(self.options)):
print(f"| {i}). {self.options[i]['title']}")
print(f"\-------------------------------")
print("")
return self
def input_option(self):
try:
data = input("Selection: ")
index = int(data)
if index < 0 or index > len(self.options) - 1:
print("Please enter in a valid selection.")
return self.input_option()
return self.options[index]['callback']
except:
print("Please enter in a valid selection.")
return self.input_option()