Beispiel #1
0
 def onFocus(self, controlId):
     log.debug('onFocus')
     if not self.initialized:
         return
     
     log.debug('lastfocusid = %s' % controlId)
     self.lastFocusId = controlId
     
     try:
         control = self.getControl(controlId)
         if toolkit.isButton(control):
             matches = filter(lambda c: c.control == control, self.gridCells)
             if matches:
                 self.renderProgramInfo(matches[0].program)
     except TypeError, te:
         if 'Non-Existent Control' in str(te):
             log.warn('onFocus: ' + str(te))
         else:
             raise
Beispiel #2
0
 def render(self):
     value = self.store.get(self.key)
     
     if toolkit.isButton(self.widget):
         if self.type == str:
             self.widget.setLabel(label=self.widget.getLabel(), label2=value)
         elif self.type == int:
             self.widget.setLabel(label=self.widget.getLabel(), label2=str(value))
         elif self.type == Seconds:
             self.widget.setLabel(label=self.widget.getLabel(), label2='%s seconds' % value)
         elif self.type == NegativeSeconds:
             self.widget.setLabel(label=self.widget.getLabel(), label2='%s seconds' % str(int(value) * -1))                
         else:
             raise Exception('Dont know how to handle type %s in render()' % self.type)
     elif toolkit.isRadioButton(self.widget):
         if self.type == bool:
             self.widget.setSelected(self.store.get(self.key) in ('True', 'true', '1'))
         else:
             raise Exception('Dont know how to handle type %s in render()' % self.type)
     else:
         raise Exception('Unknown widget in render(): %s with id %s' % (type(self.widget), self.widget.getId()))