fix up more bits

This commit is contained in:
chrys 2019-02-04 22:45:12 +01:00
parent f32d56a00d
commit 474fdb53b8

View File

@ -23,16 +23,18 @@ class vmenuManager():
def shutdown(self): def shutdown(self):
pass pass
def setCurrMenu(self, currMenu = ''): def setCurrMenu(self, currMenu = ''):
if currMenu == '':
self.currIndex = None self.currIndex = None
self.currMenu = '' self.currMenu = ''
else: currIndex = None
if currMenu != '':
try: try:
t = self.menuDict[currMenu] t = self.menuDict[currMenu]
l = list(menuDict.keys()) l = list(menuDict.keys())
self.currIndex = [l.index(currMenu)] currIndex = [l.index(currMenu)]
except: except:
return return
if self.incLevel():
self.currIndex = currIndex
self.currMenu = currMenu self.currMenu = currMenu
def getCurrMenu(self): def getCurrMenu(self):
return self.currMenu return self.currMenu
@ -95,43 +97,43 @@ class vmenuManager():
def incLevel(self): def incLevel(self):
if self.currIndex == None: if self.currIndex == None:
return return False
try: try:
r = self.getValueByPath(self.menuDict, self.currIndex +[0]) r = self.getValueByPath(self.menuDict, self.currIndex +[0])
print(r) print(r)
if r == {}: if r == {}:
return return False
except: except:
return return False
self.currIndex.append(0) self.currIndex.append(0)
print(self.currIndex) return True
def decLevel(self): def decLevel(self):
if self.currIndex == None: if self.currIndex == None:
return return False
if self.currMenu != '': if self.currMenu != '':
if len(self.currIndex) <= 2: if len(self.currIndex) <= 2:
return return False
elif len(self.currIndex) == 1: elif len(self.currIndex) == 1:
return return False
self.currIndex = self.currIndex[:len(self.currIndex) - 1] self.currIndex = self.currIndex[:len(self.currIndex) - 1]
print(self.currIndex) return True
def nextIndex(self): def nextIndex(self):
if self.currIndex == None: if self.currIndex == None:
return return False
if self.currIndex[len(self.currIndex) - 1] + 1 >= len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])): if self.currIndex[len(self.currIndex) - 1] + 1 >= len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])):
self.currIndex[len(self.currIndex) - 1] = 0 self.currIndex[len(self.currIndex) - 1] = 0
else: else:
self.currIndex[len(self.currIndex) - 1] += 1 self.currIndex[len(self.currIndex) - 1] += 1
print(self.currIndex) return True
def prevIndex(self): def prevIndex(self):
if self.currIndex == None: if self.currIndex == None:
return return False
if self.currIndex[len(self.currIndex) - 1] == 0: if self.currIndex[len(self.currIndex) - 1] == 0:
self.currIndex[len(self.currIndex) - 1] = len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])) - 1 self.currIndex[len(self.currIndex) - 1] = len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])) - 1
else: else:
self.currIndex[len(self.currIndex) - 1] -= 1 self.currIndex[len(self.currIndex) - 1] -= 1
print(self.currIndex) return True
def getCurrentEntry(self): def getCurrentEntry(self):
print( self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]]) print( self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]])