当前位置: 首页>>代码示例>>Python>>正文


Python SelectionList.toggleSelection方法代码示例

本文整理汇总了Python中Components.SelectionList.SelectionList.toggleSelection方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionList.toggleSelection方法的具体用法?Python SelectionList.toggleSelection怎么用?Python SelectionList.toggleSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Components.SelectionList.SelectionList的用法示例。


在下文中一共展示了SelectionList.toggleSelection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LiveStreamingLinks

# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import toggleSelection [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()
#.........这里部分代码省略.........
开发者ID:et-plugins,项目名称:et-live-links,代码行数:103,代码来源:plugin.py

示例2: IPTVStreams

# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import toggleSelection [as 别名]

#.........这里部分代码省略.........
        self.initSelectionList()
        self.xmlList = []
        self.subMenuName = fileName
        self.subMenuDescrName = descrName
        self.level = self.LEVEL_XML
        self.readChannelXml3(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 wgetUrl2(self, url2):
        std_headers = {'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
         'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
         'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
         'Accept-Language': 'en-us,en;q=0.5'}
        outtxt = Request(url2, None, std_headers)
        try:
            outtxt = urlopen(url2).read()
        except (URLError, HTTPException) as err:
            return ''

        return outtxt

    def keyOk(self):
        if self.level == self.LEVEL_FILES:
            print 'in Keyok 1'
            self.keyGo()
        elif self.level == self.LEVEL_XML:
            print 'in Keyok 2'
            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()
        tvFileList = []
        radioFileList = []
        for item in tmpList:
            if self.createUserBouquetFile(item[1], 'tv') > 0:
                tvFileList.append(item[1])
            if self.createUserBouquetFile(item[1], 'radio') > 0:
                radioFileList.append(item[1])

        if len(tvFileList) > 0:
            self.createBouquetFile(tvFileList, 'tv')
        if len(radioFileList) > 0:
            self.createBouquetFile(radioFileList, 'radio')
        db = eDVBDB.getInstance()
        db.reloadServicelist()
        db.reloadBouquets()
        self.doExit = True
        self.session.openWithCallback(self.infoCallback, MessageBox, _('Successfully Imported:\nChannels Now Available in your bouquet/Favorite list'), MessageBox.TYPE_INFO)

    def infoCallback(self, confirmed):
        if self.doExit:
开发者ID:mcron,项目名称:enigma2,代码行数:70,代码来源:plugin.py

示例3: StreamingChannelFromServerScreen

# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import toggleSelection [as 别名]
class StreamingChannelFromServerScreen(Screen):
	skin = '\n\t\t<screen name="StreamingChannelFromServerScreen" position="center,center" size="550,450" >\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<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t\t<ePixmap pixmap="skin_default/buttons/blue.png" position="420,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 source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t\t<widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t\t<widget name="list" position="5,50" size="540,360" />\n\t\t\t<ePixmap pixmap="skin_default/div-h.png" position="0,410" zPosition="10" size="560,2" transparent="1" alphatest="on" />\n\t\t\t<widget source="statusbar" render="Label" position="5,420" zPosition="10" size="550,30" halign="center" valign="center" font="Regular;22" transparent="1" shadowColor="black" shadowOffset="-1,-1" />\n\t\t</screen>'

	def __init__(self, session):
		Screen.__init__(self, session)
		Screen.setTitle(self, _('Select bouquets to convert'))
		self.session = session
		self.workList = []
		self.readIndex = 0
		self.working = False
		self.hasFiles = False
		self.list = SelectionList()
		self['list'] = self.list
		self['key_red'] = StaticText(_('Close'))
		self['key_green'] = StaticText('')
		self['key_yellow'] = StaticText(_('Set server IP'))
		self['key_blue'] = StaticText('')
		self['statusbar'] = StaticText(_('Select a remote server IP first'))
		self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'ok': self.keyOk,
		 'cancel': self.close,
		 'red': self.close,
		 'green': self.keyGreen,
		 'yellow': self.keyYellow,
		 'blue': self.keyBlue}, -1)

	def keyOk(self):
		if self.working:
			return
		if self.readIndex > 0:
			self.list.toggleSelection()

	def keyBlue(self):
		if not self.hasFiles or self.working:
			return
		if self.readIndex > 0:
			try:
				self.list.toggleAllSelection()
			except AttributeError:
				self.list.toggleSelection()

	def keyYellow(self):
		if not self.hasFiles:
			self.session.openWithCallback(self.setRemoteIpCallback, ServerEditor)

	def setRemoteIpCallback(self, ret = False):
		if ret:
			self['statusbar'].setText(_('Testing remote connection'))
			timeout = 3000
			self.currentLength = 0
			self.total = 0
			self.working = True
			creator = ClientCreator(reactor, FTPClient, config.plugins.RemoteStreamConverter.username.value, config.plugins.RemoteStreamConverter.password.value, config.plugins.RemoteStreamConverter.passive.value)
			creator.connectTCP(self.getRemoteAdress(), config.plugins.RemoteStreamConverter.port.value, timeout).addCallback(self.controlConnectionMade).addErrback(self.connectionFailed)

	def controlConnectionMade(self, ftpclient):
		self['statusbar'].setText(_('Connection to remote IP ok'))
		ftpclient.quit()
		self.fetchRemoteBouqets()

	def connectionFailed(self, *args):
		self.working = False
		self['statusbar'].setText(_('Could not connect to remote IP'))

	def fetchRemoteBouqets(self):
		self['statusbar'].setText(_('Downloading remote services'))
		self.readIndex = 0
		self.workList = []
		self.workList.append('bouquets.tv')
		self.workList.append('bouquets.radio')
		self.download(self.workList[0]).addCallback(self.fetchRemoteBouqetsFinished).addErrback(self.fetchRemoteBouqetsFailed)

	def fetchRemoteBouqetsFailed(self, string):
		self.working = False
		self['statusbar'].setText(_('Download from remote failed'))

	def fetchRemoteBouqetsFinished(self, string):
		self.readIndex += 1
		if self.readIndex < len(self.workList):
			self.download(self.workList[self.readIndex]).addCallback(self.fetchRemoteBouqetsFinished).addErrback(self.fetchRemoteBouqetsFailed)
		else:
			self.parseBouqets()

	def parserWork(self, list, name):
		file = open(name)
		lines = file.readlines()
		file.close()
		if len(lines) > 0:
			for line in lines:
				if line.startswith('#SERVICE'):
					line = line.replace('\n', '').replace('\r', '').split()
					if not int(line[1].split(':')[1]) & eServiceReference.isInvisible:
						if len(line) > 3 and line[2] == 'BOUQUET' and (line[3].find('.tv') != -1 or line[3].find('.radio')):
							tmp = line[3].replace('"', '')
							if len(tmp) > 1 and tmp not in list:
								list.append(tmp)
						elif line[1].find('0:0:0:0:0:0:0:'):
							tmp = line[1].split('0:0:0:0:0:0:0:')
							if tmp[1] not in list:
								list.append(tmp[1])

#.........这里部分代码省略.........
开发者ID:OpenLD,项目名称:enigma2,代码行数:103,代码来源:plugin.py

示例4: StreamingChannelFromServerScreen

# 需要导入模块: from Components.SelectionList import SelectionList [as 别名]
# 或者: from Components.SelectionList.SelectionList import toggleSelection [as 别名]
class StreamingChannelFromServerScreen(Screen):
	window_title = _("Select bouquets to convert")
	skin = """
		<screen name="StreamingChannelFromServerScreen" position="center,center" size="550,450" title="%s" >
			<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,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 source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
			<widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
			<widget name="list" position="5,50" size="540,360" />
			<ePixmap pixmap="skin_default/div-h.png" position="0,410" zPosition="10" size="560,2" transparent="1" alphatest="on" />
			<widget source="statusbar" render="Label" position="5,420" zPosition="10" size="550,30" halign="center" valign="center" font="Regular;22" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
		</screen>""" % (window_title)

	def __init__(self, session):
		Screen.__init__(self, session)
		self.session = session
		self.workList = []
		self.readIndex = 0
		self.working = False
		self.hasFiles = False
		self.list = SelectionList()
		self["list"] = self.list
		self["key_red"] = StaticText(_("Close"))
		self["key_green"] = StaticText("")
		self["key_yellow"] = StaticText(_("Set server IP"))
		self["key_blue"] = StaticText("")
		self["statusbar"] = StaticText(_("Select a remote server IP first"))
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"ok": self.keyOk,
			"cancel": self.close,
			"red": self.close,
			"green": self.keyGreen,
			"yellow": self.keyYellow,
			"blue": self.keyBlue
		}, -1)

	def keyOk(self):
		if self.working:
			return
		if self.readIndex > 0:
			self.list.toggleSelection()

	def keyBlue(self):
		if not self.hasFiles or self.working:
			return
		if self.readIndex > 0:
			try:
				self.list.toggleAllSelection()
			except AttributeError:
				self.list.toggleSelection()

	def keyYellow(self):
		if not self.hasFiles:
			self.session.openWithCallback(self.setRemoteIpCallback, ServerEditor)

	def setRemoteIpCallback(self, ret = False):
		if ret:
			self["statusbar"].setText(_("Testing remote connection"))
			timeout = 3000
			self.currentLength = 0
			self.total = 0
			self.working = True
			creator = ClientCreator(reactor, FTPClient, config.plugins.RemoteStreamConverter.username.value, config.plugins.RemoteStreamConverter.password.value, config.plugins.RemoteStreamConverter.passive.value)
			creator.connectTCP(self.getRemoteAdress(), config.plugins.RemoteStreamConverter.port.value, timeout).addCallback(self.controlConnectionMade).addErrback(self.connectionFailed)

	def controlConnectionMade(self, ftpclient):
		self["statusbar"].setText(_("Connection to remote IP ok"))
		ftpclient.quit()
		self.fetchRemoteBouqets()

	def connectionFailed(self, *args):
		self.working = False
		self["statusbar"].setText(_("Could not connect to remote IP"))

	def fetchRemoteBouqets(self):
		self["statusbar"].setText(_("Downloading remote services"))
		self.readIndex = 0
		self.workList = []
		self.workList.append('bouquets.tv')
		self.workList.append('bouquets.radio')
		self.download(self.workList[0]).addCallback(self.fetchRemoteBouqetsFinished).addErrback(self.fetchRemoteBouqetsFailed)

	def fetchRemoteBouqetsFailed(self, string):
		self.working = False
		self["statusbar"].setText(_("Download from remote failed"))

	def fetchRemoteBouqetsFinished(self, string):
		self.readIndex += 1
		if self.readIndex < len(self.workList):
			self.download(self.workList[self.readIndex]).addCallback(self.fetchRemoteBouqetsFinished).addErrback(self.fetchRemoteBouqetsFailed)
		else:
			self.parseBouqets()

	def parserWork(self, list, name):
		try:
#.........这里部分代码省略.........
开发者ID:blzr,项目名称:e2openplugin-RemoteChannelStreamConverter,代码行数:103,代码来源:plugin.py


注:本文中的Components.SelectionList.SelectionList.toggleSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。