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


Python ListBox.isItemSelected方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import isItemSelected [as 别名]

#.........这里部分代码省略.........
			try:
			# For some reason the '0x' at the start of the string is causing exceptions,
			# even though it works fine with interactive python. I'll take it off anyway.
				string=sender.getText()
				if( len(string)>=2 ) :
					if string[0]=='0' and string[1]=='x' : string=string[2:]
					value=int( string, 16 ) # convert as hex
					# Cap values at 255
					if value<0 : value=0
					if value>255 : value=255
					sender.setStyleAttribute( "background-color", "#FFFFFF" )
			# Convert to the same format as everything else
				sender.setText( "0x%02x"%value )
			# Send the change to the RPC service
				messageParameters = {}
				for cbcName in self.getActiveCBCs() :
					messageParameters[cbcName]={ sender.getTitle():value }
					self.rpcService.setI2CRegisterValues( messageParameters, I2CPanel.RefreshListener(self) )
			
			except ValueError:
				sender.setStyleAttribute( "background-color", "#FF3333" )		
		
		#self.echoSelection()
	
	def echoSelection(self): #fb - a good "print screen" method
		msg = " File saved: "
		for names in self.getCheckedStates():
			msg += names
		self.echo.setText(msg)	
			
	def getList(self):
		selectCBCs = []
		for i in range(self.cbcList.getItemCount()) :
			if self.cbcList.isItemSelected(i):
				selectedCBCs.append(self.cbcList.getItemText(i))
				
	def getTotalCBCs(self) : #fb
		totalCBCs = []
		for i in range(self.cbcList.getItemCount()) :
			totalCBCs.append(self.cbcList.getItemText(i))
		return totalCBCs
	
	def getSpecificCBC(self, i): #fb
		specificCBC = []
		specificCBC.append(self.cbcList.getItemText(i))
		return specificCBC
		

	def getActiveCBCs(self) :
		selectedCBCs = []
		for i in range(self.cbcList.getItemCount()) :
			if self.cbcList.isItemSelected(i):
				selectedCBCs.append(self.cbcList.getItemText(i))
		return selectedCBCs
	
	def getCheckedStates(self): # returns the checked boxes + filename
		selectedStates = []
		#for names in self.stateValueEntries:
			#if str(self.stateValueEntries[names].isChecked())=="True":
			#	selectedStates.append(names)
		selectedStates.append(self.saveFileName.getText())
		return selectedStates
		
	def createRegisterPanel( self, registerNames ) :
		"""
		Creates panels and buttons for everything given in registerNames, and returns the main panel.
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:70,代码来源:I2CPanel.py

示例2: Lists

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import isItemSelected [as 别名]
class Lists(Sink):
    def __init__(self):
        Sink.__init__(self)

        self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"],
            ["foo1", "bar1", "baz1", "toto1", "tintin1"],
            ["foo2", "bar2", "baz2", "toto2", "tintin2"],
            ["foo3", "bar3", "baz3", "toto3", "tintin3"],
            ["foo4", "bar4", "baz4", "toto4", "tintin4"]]

        self.combo=ListBox(VisibleItemCount=1)
        self.list=ListBox(MultipleSelect=True, VisibleItemCount=10)
        self.echo=Label()

        self.combo.addChangeListener(self)

        for i in range(len(self.sStrings)):
            txt = "List %d" % i
            self.combo.addItem(txt)
            # test setItemText
            self.combo.setItemText(i, txt + " using set text")
        self.combo.setSelectedIndex(0)
        self.fillList(0)
        self.list.setItemSelected(0, False)
        self.list.setItemSelected(1, True)

        self.list.addChangeListener(self)

        horz = HorizontalPanel(VerticalAlignment=HasAlignment.ALIGN_TOP,
                               Spacing=8)
        horz.add(self.combo)
        horz.add(self.list)

        panel = VerticalPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT)
        panel.add(horz)
        panel.add(self.echo)
        self.initWidget(panel)

        self.echoSelection()

    def onChange(self, sender):
        if sender == self.combo:
            self.fillList(self.combo.getSelectedIndex())
        elif sender == self.list:
            self.echoSelection()

    def onShow(self):
        pass

    def fillList(self, idx):
        self.list.clear()
        strings = self.sStrings[idx]
        for i in range(len(strings)):
            self.list.addItem(strings[i])

        self.echoSelection()

    def echoSelection(self):
        msg = "Selected items: "
        for i in range(self.list.getItemCount()):
            if self.list.isItemSelected(i):
                msg += self.list.getItemText(i) + " "
        self.echo.setText(msg)
开发者ID:Afey,项目名称:pyjs,代码行数:65,代码来源:Lists.py

示例3: DisplayHistogramsView

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import isItemSelected [as 别名]
class DisplayHistogramsView(object) :
	"""
	@brief View in the MVP pattern for displaying histograms.

	@author Mark Grimes ([email protected])
	@date 09/Feb/2014
	"""
	def __init__( self ) :
		self.cbcList=ListBox(MultipleSelect=True, VisibleItemCount=4)
		self.channelList=ListBox(MultipleSelect=True, VisibleItemCount=20)
		self.updateButton=Button("Update")

		controls=VerticalPanel()
		controls.add(self.updateButton)
		controls.add(self.cbcList)
		controls.add(self.channelList)

		controls.setCellHorizontalAlignment( self.updateButton, HasHorizontalAlignment.ALIGN_CENTER )
		self.cbcList.setWidth("95%")
		self.channelList.setWidth("95%")

		self.cbcList.addItem( "waiting..." )
		for index in range(0,254) :
			self.channelList.addItem( "Channel %3d"%index )

		self.histogram = Image()
		self.mainPanel = HorizontalPanel()
		self.mainPanel.add( controls )
		self.mainPanel.add( self.histogram )
		self.histogram.setUrl( "defaultScurveHistogram.png" )

	def getPanel( self ) :
		return self.mainPanel

	def setAvailableCBCs( self, cbcNames ) :
		self.cbcList.clear()
		for name in cbcNames :
			self.cbcList.addItem( name )

	def enable( self ) :
		self.updateButton.setEnabled(True)
		self.cbcList.setEnabled(True)
		self.channelList.setEnabled(True)

	def disable( self ) :
		self.updateButton.setEnabled(False)
		self.cbcList.setEnabled(False)
		self.channelList.setEnabled(False)
	
	def getUpdateButton( self ) :
		return self.updateButton
	
	def getSelectedCBCChannels( self ) :
		"""
		Returns a dictionary of which channels are selected, with CBC name as a key and
		an array of the channels for that CBC as the value.
		"""
		# The way this view is currently set up, the selected channels have to be the same
		# for each selected CBC.
		selectedChannels=[]
		for index in range(self.channelList.getItemCount()) :
			if self.channelList.isItemSelected(index) :
				selectedChannels.append(index)
		returnValue={}
		for index in range(self.cbcList.getItemCount()) :
			if self.cbcList.isItemSelected(index) : returnValue[self.cbcList.getItemText(index)]=selectedChannels

		return returnValue

	def setImage( self, url ) :
		self.histogram.setUrl( url )
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:73,代码来源:DisplayHistogramsPanel.py


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