34 lines
641 B
Python
34 lines
641 B
Python
from enum import Enum, auto
|
|
|
|
|
|
class Menu:
|
|
values: list
|
|
|
|
def __init__(self):
|
|
self.position = 0
|
|
|
|
def go_up(self) -> None:
|
|
self.position = max(0, self.position - 1)
|
|
|
|
def go_down(self) -> None:
|
|
self.position = min(len(self.values) - 1, self.position + 1)
|
|
|
|
def validate(self) -> None:
|
|
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
|