本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.setItemText方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.setItemText方法的具体用法?Python ListBox.setItemText怎么用?Python ListBox.setItemText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.setItemText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Lists
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setItemText [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)