Better menus

This commit is contained in:
Nicolas Margulies 2020-11-06 16:40:43 +01:00
parent 60ca00b8fa
commit 901406351e
1 changed files with 22 additions and 3 deletions

View File

@ -1,7 +1,11 @@
from enum import Enum, auto
class Menu: class Menu:
def __init__(self, values:list): values:list
self.values = values
def __init__(self):
self.position = 0 self.position = 0
def go_up(self): def go_up(self):
@ -11,4 +15,19 @@ class Menu:
self.position = min(len(self.values)-1, self.position +1) self.position = min(len(self.values)-1, self.position +1)
def validate(self): def validate(self):
return self.values[self.position] return self.values[self.position]
class MainMenuValues(Enum):
START = auto()
SETTINGS = auto()
EXIT = auto()
class MainMenu(Menu):
values = [ e for e in MainMenuValues ]
class ArbitraryMenu:
def __init__(self, values:list):
super().__init__(self)
self.values = values