Generic menu implementation
This commit is contained in:
parent
bfce9487c5
commit
60ca00b8fa
|
@ -0,0 +1,14 @@
|
|||
class Menu:
|
||||
|
||||
def __init__(self, values:list):
|
||||
self.values = values
|
||||
self.position = 0
|
||||
|
||||
def go_up(self):
|
||||
self.position = max(0, self.position -1)
|
||||
|
||||
def go_down(self):
|
||||
self.position = min(len(self.values)-1, self.position +1)
|
||||
|
||||
def validate(self):
|
||||
return self.values[self.position]
|
Loading…
Reference in New Issue