本文整理汇总了Python中Components.SelectionList.SelectionList.addSelection方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionList.addSelection方法的具体用法?Python SelectionList.addSelection怎么用?Python SelectionList.addSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Components.SelectionList.SelectionList
的用法示例。
在下文中一共展示了SelectionList.addSelection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CAidSelect
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class CAidSelect(Screen):
skin = '\n\t\t<screen name="CAidSelect" position="center,center" size="450,440" title="select CAId\'s" >\n\t\t\t<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t\t<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t\t<widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t\t<widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t\t<widget name="list" position="5,50" size="440,330" scrollbarMode="showOnDemand" />\n\t\t\t<ePixmap pixmap="skin_default/div-h.png" position="0,390" zPosition="1" size="450,2" />\n\t\t\t<widget source="introduction" render="Label" position="0,400" size="450,40" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />\n\t\t</screen>'
def __init__(self, session, list, selected_caids):
Screen.__init__(self, session)
self.list = SelectionList()
self['list'] = self.list
for listindex in range(len(list)):
if find_in_list(selected_caids, list[listindex][0], 0):
self.list.addSelection(list[listindex][0], list[listindex][1], listindex, True)
else:
self.list.addSelection(list[listindex][0], list[listindex][1], listindex, False)
self['key_red'] = StaticText(_('Cancel'))
self['key_green'] = StaticText(_('Save'))
self['introduction'] = StaticText(_('Press OK to select/deselect a CAId.'))
self['actions'] = ActionMap(['ColorActions', 'SetupActions'], {'ok': self.list.toggleSelection,
'cancel': self.cancel,
'green': self.greenPressed,
'red': self.cancel}, -1)
self.onShown.append(self.setWindowTitle)
def setWindowTitle(self):
self.setTitle(_("select CAId's"))
def greenPressed(self):
list = self.list.getSelectionsList()
print list
self.close(list)
def cancel(self):
self.close()
示例2: IpkgInstaller
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class IpkgInstaller(Screen):
def __init__(self, session, list):
Screen.__init__(self, session)
Screen.setTitle(self, _("IPK Installer"))
self.list = SelectionList()
self["list"] = self.list
for listindex in range(len(list)):
if not list[listindex].split('/')[-1].startswith('._'):
self.list.addSelection(list[listindex].split('/')[-1], list[listindex], listindex, False)
self["key_red"] = StaticText(_("Close"))
self["key_green"] = StaticText(_("Install"))
self["key_yellow"] = StaticText()
self["key_blue"] = StaticText(_("Invert"))
self["introduction"] = StaticText(_("Press OK to toggle the selection."))
self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
{
"ok": self.list.toggleSelection,
"cancel": self.close,
"red": self.close,
"green": self.install,
"blue": self.list.toggleAllSelection
}, -1)
def install(self):
list = self.list.getSelectionsList()
cmdList = []
for item in list:
cmdList.append((IpkgComponent.CMD_INSTALL, {"package": item[1]}))
self.session.open(Ipkg, cmdList=cmdList)
示例3: IpkgInstaller
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class IpkgInstaller(Screen):
def __init__(self, session, list):
Screen.__init__(self, session)
Screen.setTitle(self, _('IPK Installer'))
self.list = SelectionList()
self['list'] = self.list
for listindex in range(len(list)):
if not list[listindex].split('/')[-1].startswith('._'):
self.list.addSelection(list[listindex].split('/')[-1], list[listindex], listindex, False)
self['key_red'] = StaticText(_('Close'))
self['key_green'] = StaticText(_('Install'))
self['key_yellow'] = StaticText()
self['key_blue'] = StaticText(_('Invert'))
self['introduction'] = StaticText(_('Press OK to toggle the selection.'))
self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'ok': self.list.toggleSelection,
'cancel': self.close,
'red': self.close,
'green': self.install,
'blue': self.list.toggleAllSelection}, -1)
def install(self):
list = self.list.getSelectionsList()
cmdList = []
for item in list:
cmdList.append((IpkgComponent.CMD_INSTALL, {'package': item[1]}))
self.session.open(Ipkg, cmdList=cmdList)
示例4: CAidSelect
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class CAidSelect(Screen):
skin = """
<screen name="CAidSelect" position="center,120" size="820,520" title="select CAId's">
<ePixmap pixmap="skin_default/buttons/red.png" position="10,5" size="200,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/green.png" position="210,5" size="200,40" alphatest="on" />
<widget source="key_red" render="Label" position="10,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
<widget source="key_green" render="Label" position="210,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
<eLabel position="10,50" size="800,1" backgroundColor="grey" />
<widget name="list" position="10,55" size="800,420" enableWrapAround="1" scrollbarMode="showOnDemand" />
<eLabel position="10,480" size="800,1" backgroundColor="grey" />
<widget source="introduction" render="Label" position="10,488" size="800,25" font="Regular;22" halign="center" />
</screen>"""
def __init__(self, session, list, selected_caids):
Screen.__init__(self, session)
self.list = SelectionList()
self["list"] = self.list
for listindex in range(len(list)):
if find_in_list(selected_caids,list[listindex][0],0):
self.list.addSelection(list[listindex][0], list[listindex][1], listindex, True)
else:
self.list.addSelection(list[listindex][0], list[listindex][1], listindex, False)
self["key_red"] = StaticText(_("Cancel"))
self["key_green"] = StaticText(_("Save"))
self["introduction"] = StaticText(_("Press OK to select/deselect a CAId."))
self["actions"] = ActionMap(["ColorActions","SetupActions"],
{
"ok": self.list.toggleSelection,
"cancel": self.cancel,
"green": self.greenPressed,
"red": self.cancel
}, -1)
self.onShown.append(self.setWindowTitle)
def setWindowTitle(self):
self.setTitle(_("select CAId's"))
def greenPressed(self):
list = self.list.getSelectionsList()
print list
self.close(list)
def cancel(self):
self.close()
示例5: CAidSelect
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class CAidSelect(Screen):
skin = """
<screen name="CAidSelect" position="center,center" size="450,440" title="select CAId's" >
<ePixmap pixmap="buttons/red.png" position="0,0" size="140,40" alphatest="on" />
<ePixmap pixmap="buttons/green.png" position="140,0" size="140,40" alphatest="on" />
<widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
<widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
<widget name="list" position="5,50" size="440,330" scrollbarMode="showOnDemand" />
<ePixmap pixmap="div-h.png" position="0,390" zPosition="1" size="450,2" />
<widget source="introduction" render="Label" position="0,400" size="450,40" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
</screen>"""
def __init__(self, session, list, selected_caids):
Screen.__init__(self, session)
self.list = SelectionList()
self["list"] = self.list
for listindex in range(len(list)):
if find_in_list(selected_caids,list[listindex][0],0):
self.list.addSelection(list[listindex][0], list[listindex][1], listindex, True)
else:
self.list.addSelection(list[listindex][0], list[listindex][1], listindex, False)
self["key_red"] = StaticText(_("Cancel"))
self["key_green"] = StaticText(_("Save"))
self["introduction"] = StaticText(_("Press OK to select/deselect a CAId."))
self["actions"] = ActionMap(["ColorActions","SetupActions"],
{
"ok": self.list.toggleSelection,
"cancel": self.cancel,
"green": self.greenPressed,
"red": self.cancel
}, -1)
self.onShown.append(self.setWindowTitle)
def setWindowTitle(self):
self.setTitle(_("select CAId's"))
def greenPressed(self):
list = self.list.getSelectionsList()
self.close(list)
def cancel(self):
self.close()
示例6: LiveStreamingLinks
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class LiveStreamingLinks(Screen):
LIST_NAME = 0
LIST_CAT = 1
LIST_TYPE = 2
LIST_URL = 3
LEVEL_FILES = 0
LEVEL_XML = 1
DIR_ENIGMA2 = '/etc/enigma2/'
URL_BASE = 'http://et-live-links.googlecode.com/svn/trunk/'
skin = """
<screen position="c-300,c-210" size="600,420" title="">
<widget name="list" position="10,10" size="e-20,205" scrollbarMode="showOnDemand" />
<widget source="info" render="Label" position="10,215" size="e-20,200" halign="center" valign="top" font="Regular;17" />
<ePixmap pixmap="skin_default/buttons/red.png" position="c-150,e-45" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/green.png" position="c-0,e-45" size="140,40" alphatest="on" />
<widget source="key_red" render="Label" position="c-150,e-45" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
<widget source="key_green" render="Label" position="c-0,e-45" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
</screen>"""
def __init__(self, session):
self.skin = LiveStreamingLinks.skin
Screen.__init__(self, session)
self["key_red"] = StaticText(_("Cancel"))
self["key_green"] = StaticText(_("Download"))
self["actions"] = ActionMap(["SetupActions", "ColorActions"],
{
"ok": self.keyOk,
"save": self.keyGo,
"cancel": self.keyCancel,
"green": self.keyGo,
"red": self.keyCancel,
}, -2)
self.list = SelectionList()
self["list"] = self.list
self["info"] = StaticText("")
self.doExit = False
self.level = self.LEVEL_FILES
self.subMenuName = ''
self.subMenuDescrName = ''
self.xmlFiles = []
self.xmlCategories = []
self.lastchanged = ''
self.lastchanges = ''
self.onLayoutFinish.append(self.createTopMenu)
def initSelectionList(self):
list = []
self.list.setList(list)
def createTopMenu(self):
self.setTitle(_("ET-Livestream importer"))
self.initSelectionList()
self.subMenuName = ''
self.subMenuDescrName = ''
self.level = self.LEVEL_FILES
self.readMainXml()
count = 0
for x in self.xmlFiles:
self.list.addSelection(x[self.LIST_CAT], x[self.LIST_NAME], count, False)
count += 1
self["info"].setText("")
def readXmlSubFile(self, fileName, descrName):
self.initSelectionList()
self.xmlList = []
self.subMenuName = fileName
self.subMenuDescrName = descrName
self.level = self.LEVEL_XML
self.readChannelXml(self.xmlList, fileName)
tmp = _('Last update') + ': %s\n\n%s' % (self.lastchanged, self.lastchanges)
self["info"].setText(tmp)
count = 0
for x in self.xmlCategories:
self.list.addSelection(x, x, count, False)
count += 1
def keyOk(self):
if self.level == self.LEVEL_FILES:
self.keyGo()
elif self.level == self.LEVEL_XML:
if len(self.xmlCategories) > 0:
self.list.toggleSelection()
def keyGo(self):
if self.level == self.LEVEL_FILES:
self.readXmlSubFile(self.xmlFiles[self.list.getSelectedIndex()][self.LIST_NAME], self.xmlFiles[self.list.getSelectedIndex()][self.LIST_CAT])
return
self.doExit = False
tmpList = []
tmpList = self.list.getSelectionsList()
if len(tmpList) == 0:
self.session.openWithCallback(self.infoCallback, MessageBox, _("Nothing selected"), MessageBox.TYPE_INFO)
return
self.xmlList.sort()
#.........这里部分代码省略.........
示例7: StreamingChannelFromServerScreen
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
#.........这里部分代码省略.........
self.workList.append('lamedb')
self.download(self.workList[0]).addCallback(self.fetchUserBouquetsFinished).addErrback(self.fetchUserBouquetsFailed)
def fetchUserBouquetsFailed(self, string):
print 'string', string
if self.readIndex < len(self.workList) and self.readIndex > 0:
self.workList.remove(self.workList[self.readIndex])
self.readIndex -= 1
self.fetchUserBouquetsFinished('')
self.working = False
self['statusbar'].setText(_('Download from remote failed'))
def fetchUserBouquetsFinished(self, string):
self.readIndex += 1
if self.readIndex < len(self.workList):
self['statusbar'].setText(_('FTP reading bouquets %d of %d') % (self.readIndex, len(self.workList) - 1))
self.download(self.workList[self.readIndex]).addCallback(self.fetchUserBouquetsFinished).addErrback(self.fetchUserBouquetsFailed)
elif len(self.workList) > 0:
self.findAlternatives()
self.alternativesCounter = 0
if len(self.alternatives) > 0:
self.download(self.alternatives[self.alternativesCounter]).addCallback(self.downloadAlternativesCallback).addErrback(self.downloadAlternativesErrback)
self['statusbar'].setText(_('Make your selection'))
self.editBouquetNames()
bouquetFilesContents = ''
for suffix in ['tv', 'radio']:
fp = open(DIR_ENIGMA2 + 'bouquets.' + suffix)
bouquetFilesContents += fp.read()
fp.close()
for listindex in range(len(self.workList) - 1):
truefalse = self.workList[listindex] in bouquetFilesContents
name = self.readBouquetName(DIR_TMP + self.workList[listindex])
self.list.addSelection(name, self.workList[listindex], listindex, truefalse)
self.removeFiles(DIR_TMP, 'bouquets.')
self.working = False
self.hasFiles = True
self['key_green'].setText(_('Download'))
self['key_blue'].setText(_('Invert'))
self['key_yellow'].setText('')
def download(self, file, contextFactory = None, *args, **kwargs):
client = FTPDownloader(self.getRemoteAdress(), config.plugins.RemoteStreamConverter.port.value, (DIR_ENIGMA2 + file), (DIR_TMP + file), config.plugins.RemoteStreamConverter.username.value, config.plugins.RemoteStreamConverter.password.value, *args, **kwargs)
return client.deferred
def convertBouquets(self):
self.readIndex = 0
while True:
if 'lamedb' not in self.workList[self.readIndex]:
filename = DIR_TMP + self.workList[self.readIndex]
fp = open(DIR_ENIGMA2 + self.workList[self.readIndex], 'w')
try:
fp2 = open(filename)
lines = fp2.readlines()
fp2.close()
was_html = False
for line in lines:
if was_html and '#DESCRIPTION' in line:
was_html = False
continue
if '#NAME' in line:
txt = _('remote of')
line = '%s (%s %s) \n' % (line.rstrip('\n'), txt, self.getRemoteAdress())
was_html = False
if 'http' in line:
示例8: IPTVStreams
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
class IPTVStreams(Screen):
LIST_NAME = 0
LIST_CAT = 1
LIST_TYPE = 2
LIST_URL = 3
LEVEL_FILES = 0
LEVEL_XML = 1
DIR_ENIGMA2 = '/etc/enigma2/'
url2 = 'http://et-live-links.googlecode.com/svn/trunk/'
main1 = 'http://'
main2 = 'livestream'
main3 = '.et-view-support.com'
main4 = '/testing/'
skin = '''<screen position="c-300,c-210" size="600,420" title="">
<widget name="list" position="10,10" size="e-20,210" scrollbarMode="showOnDemand" />
<widget source="info" render="Label" position="10,250" size="e-20,80" halign="center" valign="top" font="Regular;17" />
<ePixmap pixmap="skin_default/buttons/green.png" position="c-150,e-45" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/yellow.png" position="c-0,e-45" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/red.png" position="c-300,e-45" size="140,40" alphatest="on" />
<widget source="key_green" render="Label" position="c-150,e-45" zPosition="1" size="140,40" font="Regular;16" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
<widget source="key_red" render="Label" position="c-300,e-45" zPosition="1" size="140,40" font="Regular;16" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
<widget source="key_yellow" render="Label" position="c-0,e-45" zPosition="1" size="140,40" font="Regular;16" halign="center" valign="center" backgroundColor="#a58b00" transparent="1" />
</screen>'''
def __init__(self, session):
self.skin = IPTVStreams.skin
Screen.__init__(self, session)
self['key_red'] = StaticText(_('Cancel'))
self['key_yellow'] = StaticText(_('Change\nStreams'))
self['key_green'] = StaticText(_('Download'))
self['actions'] = ActionMap(['SetupActions', 'NumberActions', 'ColorActions'], {'ok': self.keyOk,
'save': self.keyGo,
'cancel': self.keyCancel,
'yellow': self.changeMenu,
'green': self.keyGo,
'red': self.keyCancel}, -2)
self.list = SelectionList()
self['list'] = self.list
self['info'] = StaticText('')
self.doExit = False
self.level = self.LEVEL_FILES
self.subMenuName = ''
self.subMenuDescrName = ''
self.xmlFiles = []
self.xmlCategories = []
self.lastchanged = ''
self.lastchanges = ''
self.onLayoutFinish.append(self.createTopMenu)
def changeMenu(self):
global STREAM
if STREAM == 1:
self.createTopMenu2()
elif STREAM == 2:
self.createTopMenu3()
elif STREAM == 3:
self.createTopMenu()
def initSelectionList(self):
list = []
self.list.setList(list)
def createTopMenu(self):
global STREAM
STREAM = 1
self.setTitle(_('IPTV Streams'))
self.initSelectionList()
self.subMenuName = ''
self.subMenuDescrName = ''
self.level = self.LEVEL_FILES
self.readMainXml()
count = 0
for x in self.xmlFiles:
self.list.addSelection(x[self.LIST_CAT], x[self.LIST_NAME], count, False)
count += 1
self['info'].setText('Streamlinks 1')
def createTopMenu2(self):
global STREAM
STREAM = 2
self.setTitle(_('IPTV Streams'))
self.initSelectionList()
self.subMenuName = ''
self.subMenuDescrName = ''
self.level = self.LEVEL_FILES
self.readMainXml2()
count = 0
for x in self.xmlFiles:
self.list.addSelection(x[self.LIST_CAT], x[self.LIST_NAME], count, False)
count += 1
self['info'].setText('Streamslinks 2')
def createTopMenu3(self):
global STREAM
STREAM = 3
#.........这里部分代码省略.........
示例9: StreamingChannelFromServerScreen
# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import addSelection [as 别名]
#.........这里部分代码省略.........
list.append(tmp2[0])
except:
pass
def parseBouqets(self):
list = []
self.parserWork(list, DIR_TMP + 'bouquets.tv')
self.parserWork(list, DIR_TMP + 'bouquets.radio')
self.readIndex = 0
self.workList = []
for listindex in range(len(list)):
self.workList.append('userbouquet.' + list[listindex])
self.workList.append('lamedb')
self.download(self.workList[0]).addCallback(self.fetchUserBouquetsFinished).addErrback(self.fetchUserBouquetsFailed)
def fetchUserBouquetsFailed(self, string):
if self.readIndex < len(self.workList) and self.readIndex > 0:
self.workList.remove(self.workList[self.readIndex])
self.readIndex -= 1
self.fetchUserBouquetsFinished('')
self.working = False
self["statusbar"].setText(_("Download from remote failed"))
def fetchUserBouquetsFinished(self, string):
self.readIndex += 1
if self.readIndex < len(self.workList):
self["statusbar"].setText(_("FTP reading file %d of %d") % (self.readIndex, len(self.workList)))
self.download(self.workList[self.readIndex]).addCallback(self.fetchUserBouquetsFinished).addErrback(self.fetchUserBouquetsFailed)
else:
if len(self.workList) > 0:
self["statusbar"].setText(_("Make your selection"))
for listindex in range(len(self.workList) - 1):
name = self.readBouquetName(DIR_TMP + self.workList[listindex])
self.list.addSelection(name, self.workList[listindex], listindex, False)
self.removeFiles(DIR_TMP, "bouquets.")
self.working = False
self.hasFiles = True
self["key_green"].setText(_("Download"))
self["key_blue"].setText(_("Invert"))
self["key_yellow"].setText("")
def download(self, file, contextFactory = None, *args, **kwargs):
client = FTPDownloader(
self.getRemoteAdress(),
config.plugins.RemoteStreamConverter.port.value,
DIR_ENIGMA2 + file,
DIR_TMP + file,
config.plugins.RemoteStreamConverter.username.value,
config.plugins.RemoteStreamConverter.password.value,
*args,
**kwargs
)
return client.deferred
def convertBouquets(self):
self.readIndex = 0
while True:
if 'lamedb' not in self.workList[self.readIndex]:
filename = DIR_TMP + self.workList[self.readIndex]
hasRemoteTag = False
if self.checkBouquetAllreadyInList(self.workList[self.readIndex], self.workList[self.readIndex]) is True:
self.workList[self.readIndex] = self.workList[self.readIndex].replace('userbouquet.', 'userbouquet.remote_')
hasRemoteTag = True
fp = open(DIR_ENIGMA2 + self.workList[self.readIndex], 'w')
try: