本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.setWidth方法的具体用法?Python ListBox.setWidth怎么用?Python ListBox.setWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.setWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: graybox
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [as 别名]
class graybox():
def onModuleLoad(self):
self.remote = DataService()
panel = VerticalPanel()
self.graybox = TextBox()
self.graybox.addKeyboardListener(self)
self.grayList = ListBox()
self.grayList.setVisibleItemCount(20)
self.grayList.setWidth("200px")
self.grayList.addClickListener(self)
self.Status = Label("Status Label")
panel.add(Label("Add New Task:"))
panel.add(self.graybox)
panel.add(Label("Click to Remove:"))
panel.add(self.grayList)
panel.add(self.Status)
self.remote.getTasks(self)
RootPanel().add(panel)
示例2: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [as 别名]
class SoftChordApp:
def onModuleLoad(self):
"""
Gets run when the page is first loaded.
Creates the widgets.
"""
self.remote = DataService()
main_layout = VerticalPanel()
h_layout = HorizontalPanel()
h_layout.setPadding(10)
songlist_layout = VerticalPanel()
songlist_layout.add(Label("Add New Song:"))
self.newSongTextBox = TextBox()
self.newSongTextBox.addKeyboardListener(self)
songlist_layout.add(self.newSongTextBox)
self.addSongButton = Button("Add Song")
self.addSongButton.addClickListener(self)
songlist_layout.add(self.addSongButton)
#songlist_layout.add(Label("Click to Remove:"))
self.songListBox = ListBox()
self.songListBox.setVisibleItemCount(7)
self.songListBox.setWidth("300px")
self.songListBox.setHeight("400px")
self.songListBox.addClickListener(self)
songlist_layout.add(self.songListBox)
self.deleteSongButton = Button("Delete")
self.deleteSongButton.addClickListener(self)
songlist_layout.add(self.deleteSongButton)
h_layout.add(songlist_layout)
#self.textArea = TextArea()
#self.textArea.setCharacterWidth(30)
#self.textArea.setVisibleLines(50)
#h_layout.add(self.textArea)
#self.scrollPanel = ScrollPanel(Size=("400px", "500px"))
self.songHtml = HTML("<b>Please select a song in the left table</b>")
#self.scrollPanel.add(self.songHtml)
#h_layout.add(self.scrollPanel)
h_layout.add(self.songHtml)
main_layout.add(h_layout)
self.status = Label()
main_layout.add(self.status)
RootPanel().add(main_layout)
# Populate the song table:
self.remote.getAllSongs(self)
def onKeyUp(self, sender, keyCode, modifiers):
pass
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
"""
This functon handles the onKeyPress event
"""
if keyCode == KeyboardListener.KEY_ENTER and sender == self.newSongTextBox:
id = self.remote.addSong(self.newSongTextBox.getText(), self)
self.newSongTextBox.setText("")
if id<0:
self.status.setText("Server Error or Invalid Response")
def onClick(self, sender):
"""
Gets called when a user clicked in the <sender> widget.
Currently deletes the song on which the user clicked.
"""
if sender == self.songListBox:
song_id = self.songListBox.getValue(self.songListBox.getSelectedIndex())
self.status.setText("selected song_id: %s" % song_id)
id = self.remote.getSong(song_id, self)
if id<0:
self.status.setText("Server Error or Invalid Response")
elif sender == self.addSongButton:
id = self.remote.addSong(self.newSongTextBox.getText(), self)
self.newSongTextBox.setText("")
if id<0:
self.status.setText("Server Error or Invalid Response")
elif sender == self.deleteSongButton:
#.........这里部分代码省略.........
示例3: RolePanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [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
示例4: AutoCompleteTextBox
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [as 别名]
class AutoCompleteTextBox(TextBox):
def __init__(self, **kwargs):
self.choicesPopup = PopupPanel(True, False)
self.choices = ListBox()
self.items = SimpleAutoCompletionItems()
self.popupAdded = False
self.visible = False
self.choices.addClickListener(self)
self.choices.addChangeListener(self)
self.choicesPopup.add(self.choices)
self.choicesPopup.addStyleName("AutoCompleteChoices")
self.choices.setStyleName("list")
if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-AutoCompleteTextBox"
TextBox.__init__(self, **kwargs)
self.addKeyboardListener(self)
def setCompletionItems(self, items):
if not hasattr(items, 'getCompletionItems'):
items = SimpleAutoCompletionItems(items)
self.items = items
def getCompletionItems(self):
return self.items
def onKeyDown(self, arg0, arg1, arg2):
pass
def onKeyPress(self, arg0, arg1, arg2):
pass
def onKeyUp(self, arg0, arg1, arg2):
if arg1 == KeyboardListener.KEY_DOWN:
selectedIndex = self.choices.getSelectedIndex()
selectedIndex += 1
if selectedIndex >= self.choices.getItemCount():
selectedIndex = 0
self.choices.setSelectedIndex(selectedIndex)
return
if arg1 == KeyboardListener.KEY_UP:
selectedIndex = self.choices.getSelectedIndex()
selectedIndex -= 1
if selectedIndex < 0:
selectedIndex = self.choices.getItemCount() - 1
self.choices.setSelectedIndex(selectedIndex)
return
if arg1 == KeyboardListener.KEY_ENTER:
if self.visible:
self.complete()
return
if arg1 == KeyboardListener.KEY_ESCAPE:
self.choices.clear()
self.choicesPopup.hide()
self.visible = False
return
text = self.getText()
matches = []
if len(text) > 0:
matches = self.items.getCompletionItems(text)
if len(matches) > 0:
self.choices.clear()
for i in range(len(matches)):
self.choices.addItem(matches[i])
if len(matches) == 1 and matches[0] == text:
self.choicesPopup.hide()
else:
self.choices.setSelectedIndex(0)
self.choices.setVisibleItemCount(len(matches) + 1)
if not self.popupAdded:
RootPanel().add(self.choicesPopup)
self.popupAdded = True
self.choicesPopup.show()
self.visible = True
self.choicesPopup.setPopupPosition(self.getAbsoluteLeft(), self.getAbsoluteTop() + self.getOffsetHeight())
self.choices.setWidth("%dpx" % self.getOffsetWidth())
else:
self.visible = False
self.choicesPopup.hide()
def onChange(self, arg0):
self.complete()
def onClick(self, arg0):
self.complete()
def complete(self):
#.........这里部分代码省略.........
示例5: RolePanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [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
示例6: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [as 别名]
class TodoApp:
def onModuleLoad(self):
self.remote = DataService()
panel = VerticalPanel()
self.todoTextBox = TextBox()
self.todoTextBox.addKeyboardListener(self)
self.todoList = ListBox()
self.todoList.setVisibleItemCount(7)
self.todoList.setWidth("200px")
self.todoList.addClickListener(self)
panel.add(Label("Add New Todo:"))
panel.add(self.todoTextBox)
panel.add(Label("Click to Remove:"))
panel.add(self.todoList)
self.status = Label()
panel.add(self.status)
RootPanel().add(panel)
def onKeyUp(self, sender, keyCode, modifiers):
pass
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
"""
This functon handles the onKeyPress event, and will add the item in the text box to the list when the user presses the enter key. In the future, this method will also handle the auto complete feature.
"""
if keyCode == KeyboardListener.KEY_ENTER and sender == self.todoTextBox:
id = self.remote.addTask(sender.getText(),self)
sender.setText("")
if id<0:
self.status.setText("Server Error or Invalid Response")
def onClick(self, sender):
id = self.remote.deleteTask(sender.getValue(sender.getSelectedIndex()),self)
if id<0:
self.status.setText("Server Error or Invalid Response")
def onRemoteResponse(self, response, request_info):
self.status.setText("response received")
if request_info.method == 'getTasks' or request_info.method == 'addTask' or request_info.method == 'deleteTask':
self.status.setText(self.status.getText() + "HERE!")
self.todoList.clear()
for task in response:
self.todoList.addItem(task[0])
self.todoList.setValue(self.todoList.getItemCount()-1,task[1])
else:
self.status.setText(self.status.getText() + "none!")
def onRemoteError(self, code, errobj, request_info):
message = errobj['message']
self.status.setText("Server Error or Invalid Response: ERROR %s - %s" % (code, message))
示例7: WebPageEdit
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [as 别名]
class WebPageEdit(Composite):
def __init__(self, sink):
Composite.__init__(self)
self.remote = sink.remote
panel = VerticalPanel(Width="100%", Spacing=8)
self.view = Button("View", self)
self.newpage = Button("New", self)
self.todoId = None
self.todoTextName = TextBox()
self.todoTextName.addKeyboardListener(self)
self.todoTextArea = RichTextEditor(basePath="/fckeditor/")
self.todoTextArea.setWidth("100%")
self.todoTextArea.addSaveListener(self)
self.todoList = ListBox()
self.todoList.setVisibleItemCount(7)
self.todoList.setWidth("200px")
self.todoList.addClickListener(self)
self.fDialogButton = Button("Upload Files", self)
self.status = HTML()
panel.add(HTML("Status:"))
panel.add(self.status)
panel.add(self.fDialogButton)
panel.add(Label("Create New Page (doesn't save current one!):"))
panel.add(self.newpage)
panel.add(Label("Add/Edit New Page:"))
panel.add(self.todoTextName)
panel.add(Label("Click to Load and Edit (doesn't save current one!):"))
panel.add(self.todoList)
panel.add(self.view)
panel.add(Label("New Page HTML. Click 'save' icon to save. (pagename is editable as well)"))
panel.add(self.todoTextArea)
self.setWidget(panel)
self.remote.getPages(self)
def onKeyUp(self, sender, keyCode, modifiers):
pass
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
"""
This functon handles the onKeyPress event, and will add the item in the text box to the list when the user presses the enter key. In the future, this method will also handle the auto complete feature.
"""
pass
def onSave(self, editor):
self.status.setText("")
name = self.todoTextName.getText()
if not name:
self.status.setText("Please enter a name for the page")
return
item = {"name": name, "text": self.todoTextArea.getHTML()}
if self.todoId is None:
rid = self.remote.addPage(item, self)
else:
item["id"] = self.todoId
rid = self.remote.updatePage(item, self)
if rid < 0:
self.status.setHTML("Server Error or Invalid Response")
return
def onClick(self, sender):
if sender == self.newpage:
self.todoId = None
self.todoTextName.setText("")
self.todoTextArea.setHTML("")
return
elif sender == self.view:
name = self.todoTextName.getText()
html = self.todoTextArea.getHTML()
if not html:
return
p = HTMLDialog(name, html)
p.setPopupPosition(10, 10)
p.setWidth(Window.getClientWidth() - 40)
p.setHeight(Window.getClientHeight() - 40)
p.show()
return
elif sender == self.fDialogButton:
Window.open(fileedit_url, "fileupload", "width=800,height=600")
return
dlg = FileDialog(fileedit_url)
left = self.fDialogButton.getAbsoluteLeft() + 10
top = self.fDialogButton.getAbsoluteTop() + 10
dlg.setPopupPosition(left, top)
dlg.show()
id = self.remote.getPage(sender.getValue(sender.getSelectedIndex()), self)
#.........这里部分代码省略.........
示例8: DisplayHistogramsView
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setWidth [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 )