예제 #1
0
 def _renderMenu(self):
     offset = self.activeMenuItem - (self.highlightedIndex - 1)
     if self.debugEnabled:
         debug('offset: %s' % offset)
     for i in range(0, len(self.mainMenuControls)):
         try:
             try:
                 #Show the icon if there are submenu items
                 if self.debugEnabled:
                     debug('Checking if icon is needed (Submenu in the following): %s' % pprint.pformat(self.menuDict[i + offset]))
                 if 'Submenu' in self.menuDict[i + offset]:
                     GUIHelpers.show(self.screen, self.mainMenuIconControls[i])
                     if self.debugEnabled:
                         debug('Showed icon!')
                 else:
                     GUIHelpers.hide(self.screen, self.mainMenuIconControls[i])
             except:
                 if self.debugEnabled:
                     debug('Failed checking if icon is needed')
                 pass
             if (i + offset) < 0:
                 labelBuf = ''
             else:
                 labelBuf = self.menuDict[i + offset]['Label']
         except (IndexError, KeyError):
             labelBuf = ''
         if i == (self.highlightedIndex - 1):
             try:
                 #Show the right arrow if there are submenu items
                 if self.debugEnabled:
                     debug('Checking if right arrow is needed (Submenu in the following): %s' % pprint.pformat(self.menuDict[i + offset]))
                 if 'Submenu' in self.menuDict[i + offset]:
                     GUIHelpers.show(self.screen, self.rightArrowControl)
                     if self.debugEnabled:
                         debug('Showed right arrow!')
                 else:
                     GUIHelpers.hide(self.screen, self.rightArrowControl)
             except:
                 if self.debugEnabled:
                     debug('Failed checking if right arrow is needed')
                 pass
             try:
                 #Show the left arrow if there is a parent menu
                 if self.debugEnabled:
                     debug('Checking if left arrow is needed (ParentMenu iis of type: MenuHelper) %s' % pprint.pformat(self.parentMenu))
                 if isinstance(self.parentMenu, MenuHelper):
                     GUIHelpers.show(self.screen, self.leftArrowControl)
                     if self.debugEnabled:
                         debug('Showed left arrow!')
                 else:
                     GUIHelpers.hide(self.screen, self.leftArrowControl)
             except:
                 if self.debugEnabled:
                     debug('Failed checking if left arrow is needed')
                 pass
             GUIHelpers.setBoldLabelText(self.screen, self.mainMenuControls[i], labelBuf)
         else:
             GUIHelpers.setLabelText(self.screen, self.mainMenuControls[i], labelBuf)
예제 #2
0
 def _renderSubmenu(self):
     if self.subMenuEnabled == False:
         return
     for i in range(0, len(self.subMenuControls)):
         try:
             labelBuf = self.menuDict[self.activeMenuItem]['Submenu'][i]['Label']
         except KeyError:
             labelBuf = ''
         GUIHelpers.setLabelText(self.screen, self.subMenuControls[i], labelBuf)
         if self.debugEnabled:
             debug('submenu item: %s' % labelBuf)