X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FSelectionList.py;h=1c5423fba62c512a789261a8e303067cacadec3d;hp=a64f46b4ce15aa3f7b189ccf07ed759e6166e2df;hb=6f1e7dff0f9ee7f56d48d3597d45d581057d6ce7;hpb=3239483691684e77e0ecd555e2b643e9245c37c6 diff --git a/lib/python/Components/SelectionList.py b/lib/python/Components/SelectionList.py old mode 100644 new mode 100755 index a64f46b..1c5423f --- a/lib/python/Components/SelectionList.py +++ b/lib/python/Components/SelectionList.py @@ -1,43 +1,35 @@ -from GUIComponent import GUIComponent from MenuList import MenuList -from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE -from enigma import eListboxPythonMultiContent, loadPNG, eListbox, gFont, RT_HALIGN_LEFT +from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN +from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT +from Tools.LoadPixmap import LoadPixmap -selectionpng = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "selectioncross-fs8.png")) +selectionpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/selectioncross.png")) def SelectionEntryComponent(description, value, index, selected): - res = [ (description, value, index, selected) ] - res.append((eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description)) + res = [ + (description, value, index, selected), + (eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description) + ] if selected: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 30, selectionpng)) return res -class SelectionList(MenuList, GUIComponent): - def __init__(self, list = []): - GUIComponent.__init__(self) - self.l = eListboxPythonMultiContent() - self.list = list - self.setList(list) +class SelectionList(MenuList): + def __init__(self, list = None, enableWrapAround = False): + MenuList.__init__(self, list or [], enableWrapAround, content = eListboxPythonMultiContent) self.l.setFont(0, gFont("Regular", 20)) self.l.setItemHeight(30) - GUI_WIDGET = eListbox - - def postWidgetCreate(self, instance): - instance.setContent(self.l) - def addSelection(self, description, value, index, selected = True): self.list.append(SelectionEntryComponent(description, value, index, selected)) self.setList(self.list) - + def toggleSelection(self): - item = self.list[self.getSelectedIndex()][0] - self.list[self.getSelectedIndex()] = SelectionEntryComponent(item[0], item[1], item[2], not item[3]) + idx = self.getSelectedIndex() + item = self.list[idx][0] + self.list[idx] = SelectionEntryComponent(item[0], item[1], item[2], not item[3]) self.setList(self.list) - + def getSelectionsList(self): - list = [] - for item in self.list: - if item[0][3]: - list.append((item[0][0], item[0][1], item[0][2])) - return list + return [ (item[0][0], item[0][1], item[0][2]) for item in self.list if item[0][3] ] +