本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.setItemTextSelection方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.setItemTextSelection方法的具体用法?Python ListBox.setItemTextSelection怎么用?Python ListBox.setItemTextSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.setItemTextSelection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserForm
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setItemTextSelection [as 别名]
class UserForm(AbsolutePanel):
MODE_ADD = "modeAdd";
MODE_EDIT = "modeEdit";
user = None
mode = None
usernameInput = None
firstInput = None
lastInput = None
emailInput = None
passwordInput = None
confirmInput = None
departmentCombo = None
addBtn = None
cancelBtn = None
def __init__(self,parent):
AbsolutePanel.__init__(self)
ftable = FlexTable()
ftable.setWidget(0, 0, Label("First Name", wordWrap=False))
ftableFormatter = ftable.getFlexCellFormatter()
self.firstInput = TextBox()
self.firstInput.addChangeListener(self.checkValid)
self.firstInput.addKeyboardListener(self)
ftable.setWidget(0, 1, self.firstInput)
ftable.setWidget(1, 0, Label("Last Name", wordWrap=False))
self.lastInput = TextBox()
self.lastInput.addChangeListener(self.checkValid)
self.lastInput.addKeyboardListener(self)
ftable.setWidget(1, 1, self.lastInput)
ftable.setWidget(2, 0, Label("Email", wordWrap=False))
self.emailInput = TextBox()
self.emailInput.addChangeListener(self.checkValid)
self.emailInput.addKeyboardListener(self)
ftable.setWidget(2, 1, self.emailInput)
w = Label("* Username", wordWrap=False)
w.addMouseListener(TooltipListener("Required, not changable"))
ftable.setWidget(3, 0, w)
self.usernameInput = TextBox()
self.usernameInput.addChangeListener(self.checkValid)
self.usernameInput.addKeyboardListener(self)
ftable.setWidget(3, 1, self.usernameInput)
w = Label("* Password", wordWrap=False)
w.addMouseListener(TooltipListener("Required"))
ftable.setWidget(4, 0, w)
self.passwordInput = PasswordTextBox()
self.passwordInput.addChangeListener(self.checkValid)
self.passwordInput.addKeyboardListener(self)
ftable.setWidget(4, 1, self.passwordInput)
w = Label("* Confirm", wordWrap=False)
w.addMouseListener(TooltipListener("Required"))
ftable.setWidget(5, 0, w)
self.confirmInput = PasswordTextBox()
self.confirmInput.addChangeListener(self.checkValid)
self.confirmInput.addKeyboardListener(self)
ftable.setWidget(5, 1, self.confirmInput)
w = Label("* Department", wordWrap=False)
w.addMouseListener(TooltipListener("Required"))
ftable.setWidget(6, 0, w)
self.departmentCombo = ListBox()
self.departmentCombo.addChangeListener(self.checkValid)
self.departmentCombo.addKeyboardListener(self)
ftable.setWidget(6, 1, self.departmentCombo)
hpanel = HorizontalPanel()
self.addBtn = Button("Add User")
self.addBtn.setEnabled(False)
hpanel.add(self.addBtn)
self.cancelBtn = Button("Cancel")
hpanel.add(self.cancelBtn)
ftable.setWidget(7, 0, hpanel)
ftableFormatter.setColSpan(7, 0, 2)
self.add(ftable)
self.clearForm()
return
def clearForm(self):
self.user = None
self.usernameInput.setText('')
self.firstInput.setText('')
self.lastInput.setText('')
self.emailInput.setText('')
self.passwordInput.setText('')
self.confirmInput.setText('')
self.departmentCombo.setItemTextSelection(None)
self.updateMode(self.MODE_ADD)
self.checkValid()
def updateUser(self, user):
def setText(elem, value):
#.........这里部分代码省略.........
示例2: RolePanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setItemTextSelection [as 别名]
class RolePanel(AbsolutePanel):
user = None
selectedRole = None
roleList = None
roleCombo = None
addBtn = None
removeBtn = None
def __init__(self,parent):
AbsolutePanel.__init__(self)
self.roleList = ListBox()
self.roleList.setWidth('300px')
self.roleList.setVisibleItemCount(6)
self.roleList.addChangeListener(self.onListChange)
#self.roleList.addKeyboardListener(self)
self.roleCombo = ListBox()
self.roleCombo.addKeyboardListener(self)
self.roleCombo.addChangeListener(self.onComboChange)
self.addBtn = Button("Add")
self.addBtn.setEnabled(False)
self.removeBtn = Button("Remove")
self.removeBtn.setEnabled(False)
vpanel = VerticalPanel()
vpanel.add(self.roleList)
hpanel = HorizontalPanel()
hpanel.add(self.roleCombo)
hpanel.add(self.addBtn)
hpanel.add(self.removeBtn)
vpanel.add(hpanel)
self.add(vpanel)
self.clearForm()
return
def clearForm(self):
self.user = None
self.updateRoleList([])
self.roleCombo.setItemTextSelection(None)
def updateRoleList(self,items):
self.roleList.clear()
for item in items:
self.roleList.addItem(item)
#self.roleList.addItem(' ')
#self.roleList.addItem('- - - - - - - -')
def updateRoleCombo(self,choices, default_):
self.roleCombo.clear()
for choice in choices:
self.roleCombo.addItem(choice)
self.roleCombo.selectValue(default_)
def onComboChange(self, sender, keyCode=None, modifiers=None):
selected = self.roleCombo.getSelectedItemText()
if not selected \
or selected[0] == ApplicationConstants.ROLE_NONE_SELECTED \
or not self.user:
self.addBtn.setEnabled(False)
self.selectedRole=None
else:
self.addBtn.setEnabled(True)
self.selectedRole=selected[0]
self.removeBtn.setEnabled(False)
self.roleList.setItemTextSelection(None)
def onListChange(self, sender):
selected = self.roleList.getSelectedItemText()
if selected:
self.removeBtn.setEnabled(True)
self.selectedRole=selected[0]
else:
self.removeBtn.setEnabled(False)
self.selectedRole=None
self.addBtn.setEnabled(False)
self.roleCombo.setItemTextSelection(None)
def onClick(self, sender):
pass
def onKeyUp(self, sender, keyCode, modifiers):
if sender == self.roleCombo:
self.onComboChange(sender)
elif sender == self.roleList:
self.onListChange(sender)
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
pass
示例3: RolePanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setItemTextSelection [as 别名]
class RolePanel(AbsolutePanel):
user = None
selectedRole = None
roleList = None
roleCombo = None
addBtn = None
removeBtn = None
def __init__(self,parent):
AbsolutePanel.__init__(self)
self.roleList = ListBox()
self.roleList.setWidth('300px')
self.roleList.setVisibleItemCount(6)
self.roleList.addClickListener(self.onListClick)
self.roleList.addKeyboardListener(self)
self.roleCombo = ListBox()
self.roleCombo.addClickListener(self.onComboClick)
self.roleCombo.addKeyboardListener(self)
self.addBtn = Button("Add", self)
self.addBtn.addClickListener(self.onAdd)
self.addBtn.setEnabled(False)
self.removeBtn = Button("Remove", self)
self.removeBtn.addClickListener(self.onRemove)
self.removeBtn.setEnabled(False)
vpanel = VerticalPanel()
vpanel.add(self.roleList)
hpanel = HorizontalPanel()
hpanel.add(self.roleCombo)
hpanel.add(self.addBtn)
hpanel.add(self.removeBtn)
vpanel.add(hpanel)
self.add(vpanel)
return
def updateRoleList(self,items):
self.roleList.clear()
for item in items:
self.roleList.addItem(item)
#self.roleList.addItem(' ')
#self.roleList.addItem('- - - - - - - -')
def updateRoleCombo(self,choices, default_):
self.roleCombo.clear()
for choice in choices:
self.roleCombo.addItem(choice)
self.roleCombo.selectValue(default_)
def onComboClick(self, sender, keyCode=None, modifiers=None):
selected = self.roleCombo.getSelectedItemText()
if not selected or not self.user:
self.addBtn.setEnabled(False)
self.selectedRole=None
else:
self.addBtn.setEnabled(True)
self.selectedRole=selected[0]
self.removeBtn.setEnabled(False)
self.roleList.setItemTextSelection(None)
def onListClick(self, sender):
selected = self.roleList.getSelectedItemText()
if selected:
self.removeBtn.setEnabled(True)
self.selectedRole=selected[0]
else:
self.removeBtn.setEnabled(False)
self.selectedRole=None
self.addBtn.setEnabled(False)
self.roleCombo.setItemTextSelection(None)
def onAdd(self, evt):
self.mediator.sendNotification(EmployeeAdmin.AppFacade.ADD_ROLE,self.selectedRole)
def onRemove(self,evt):
self.mediator.sendNotification(EmployeeAdmin.AppFacade.REMOVE_ROLE,self.selectedRole)
def onClick(self, sender):
pass
def onKeyUp(self, sender, keyCode, modifiers):
if sender == self.roleCombo:
self.onComboClick(sender)
elif sender == self.roleList:
self.onListClick(sender)
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
pass