def __init__(self, item): self.item = item self.component = Slider() if item.typeItem.state == "Uninitialized": self.item.typeItem.state = 0.0 addon_util.log_debug("SliderUI Uninitialized") self.label = Label(str(item.typeItem.state), alignment=ALIGN_CENTER)
def __init__(self, title, list): addon_util.log_debug("RoomWindow _init_") # You need to call base class' constructor. super(RoomWindow, self).__init__(title) # Set the window width, height and the grid resolution: 9 rows, 4 columns. self.setGeometry(850, 550, 10,4) self.listUI = [] # Create a button. buttonValidate = Button('Accept') # Place the button on the window grid. self.placeControl(buttonValidate, 9,3) # Set initial focus on the button. self.setFocus(buttonValidate) # Connect the button to a function. self.connect(buttonValidate, self.close) # Connect a key action to a function. self.connect(ACTION_NAV_BACK, self.close) #Navigation in the window self.set_active_controls(list) self.setNavigationItem() #Add Navigation link between listItem and Validate button buttonValidate.controlDown(self.listUI[0]) buttonValidate.controlUp(self.listUI[len(self.listUI)-1]) self.listUI[0].controlUp(buttonValidate) self.listUI[len(self.listUI)-1].controlDown(buttonValidate) addon_util.log_debug("Exiting RoomWindow _init_")
def __init__(self, title, list): addon_util.log_debug("RoomWindow _init_") # You need to call base class' constructor. super(RoomWindow, self).__init__(title) # Set the window width, height and the grid resolution: 9 rows, 4 columns. self.setGeometry(850, 550, 10, 4) self.listUI = [] # Create a button. buttonValidate = Button('Accept') # Place the button on the window grid. self.placeControl(buttonValidate, 9, 3) # Set initial focus on the button. self.setFocus(buttonValidate) # Connect the button to a function. self.connect(buttonValidate, self.close) # Connect a key action to a function. self.connect(ACTION_NAV_BACK, self.close) #Navigation in the window self.set_active_controls(list) self.setNavigationItem() #Add Navigation link between listItem and Validate button buttonValidate.controlDown(self.listUI[0]) buttonValidate.controlUp(self.listUI[len(self.listUI) - 1]) self.listUI[0].controlUp(buttonValidate) self.listUI[len(self.listUI) - 1].controlDown(buttonValidate) addon_util.log_debug("Exiting RoomWindow _init_")
def update(self): addon_util.log_debug("SliderUI : Update") try: self.item.typeItem.state = str(self.component.getPercent()) self.label.setLabel('%.1f' % self.component.getPercent()) openhab.updateItem(self.item) except (RuntimeError, SystemError): pass
def set_active_controls(self, list): addon_util.log_debug("set_active_controls ") self.i=1 for item in list: label_label = Label(item.typeItem.label) addon_util.log_debug("set_active_controls item: [%s]" % (item.typeItem.label)) self.tmp = self.getUI(item) if(self.i<8): self.placeControl(label_label, self.i, 0) self.placeControl(self.tmp.component, self.i, 1) else: self.placeControl(label_label, self.i%8+1, 2.25) self.placeControl(self.tmp.component, self.i%8+1, 3.25) if self.tmp.__class__.__name__ == "SliderUI": self.placeControl(self.tmp.label, self.i,0.38) self.tmp.component.setPercent(float(item.typeItem.state)) self.connectEventList([ACTION_MOVE_LEFT, ACTION_MOVE_RIGHT, ACTION_MOUSE_DRAG], self.tmp.update) elif self.tmp.__class__.__name__ == "LabelUI": pass else: self.connect(self.tmp.component, self.tmp.update) self.i=self.i+1 if self.tmp.__class__.__name__ == "ButtonSwitch" or self.tmp.__class__.__name__ == "ButtonNumber": self.listUI.append(self.tmp.component) addon_util.log_debug("exit set_active_controls ")
def set_active_controls(self, list): addon_util.log_debug("set_active_controls ") self.i = 1 for item in list: label_label = Label(item.typeItem.label) addon_util.log_debug("set_active_controls item: [%s]" % (item.typeItem.label)) self.tmp = self.getUI(item) if (self.i < 8): self.placeControl(label_label, self.i, 0) self.placeControl(self.tmp.component, self.i, 1) else: self.placeControl(label_label, self.i % 8 + 1, 2.25) self.placeControl(self.tmp.component, self.i % 8 + 1, 3.25) if self.tmp.__class__.__name__ == "SliderUI": self.placeControl(self.tmp.label, self.i, 0.38) self.tmp.component.setPercent(float(item.typeItem.state)) self.connectEventList( [ACTION_MOVE_LEFT, ACTION_MOVE_RIGHT, ACTION_MOUSE_DRAG], self.tmp.update) elif self.tmp.__class__.__name__ == "LabelUI": pass else: self.connect(self.tmp.component, self.tmp.update) self.i = self.i + 1 if self.tmp.__class__.__name__ == "ButtonSwitch" or self.tmp.__class__.__name__ == "ButtonNumber": self.listUI.append(self.tmp.component) addon_util.log_debug("exit set_active_controls ")
widgets = data['widget'] if type(widgets) is list: for w in widgets: listing.append(openHabItem(w['label'],w['item']['link'], w['item']['state'], w['item']['type'], w['widgetId'])) else : listing.append(openHabItem(widgets['label'],widgets['item']['link'], widgets['item']['state'], widgets['item']['type'], widgets['widgetId'])) return listing #Main # Info global addon_util.log("Starting") addon_util.log_debug("Debug Flag is true") base_url = sys.argv[0] thisPlugin = int(sys.argv[1]) args = urlparse.parse_qs(sys.argv[2][1:]) # Recuperation auto dans les settings de XBMC __addon__ = xbmcaddon.Addon() host = __addon__.getSetting('host') port = __addon__.getSetting('port') name = __addon__.getSetting('name') debug = __addon__.getSetting('debug') id = __addon__.getSetting('id') mode = args.get('mode', None) langage = __addon__.getLocalizedString
openHabItem(w['label'], w['item']['link'], w['item']['state'], w['item']['type'], w['widgetId'])) else: listing.append( openHabItem(widgets['label'], widgets['item']['link'], widgets['item']['state'], widgets['item']['type'], widgets['widgetId'])) return listing #Main # Info global addon_util.log("Starting") addon_util.log_debug("Debug Flag is true") base_url = sys.argv[0] thisPlugin = int(sys.argv[1]) args = urlparse.parse_qs(sys.argv[2][1:]) # Recuperation auto dans les settings de XBMC __addon__ = xbmcaddon.Addon() host = __addon__.getSetting('host') port = __addon__.getSetting('port') name = __addon__.getSetting('name') debug = __addon__.getSetting('debug') id = __addon__.getSetting('id') mode = args.get('mode', None) langage = __addon__.getLocalizedString