本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.getValue方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.getValue方法的具体用法?Python ListBox.getValue怎么用?Python ListBox.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getValue [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:
#.........这里部分代码省略.........
示例2: DirectionsSimple
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getValue [as 别名]
class DirectionsSimple(DockPanel):
def __init__(self):
DockPanel.__init__(self)
self.setSize('100%', '100%')
# widgets
topPanel = HorizontalPanel()
self.add(topPanel, DockPanel.NORTH)
places = {
"chicago, il": "Chicago",
"st louis, mo": "St Louis",
"joplin, mo": "Joplin, MO",
"oklahoma city, ok": "Oklahoma City",
"amarillo, tx": "Amarillo",
"gallup, nm": "Gallup, NM",
"flagstaff, az": "Flagstaff, AZ",
"winona, az": "Winona",
"kingman, az": "Kingman",
"barstow, ca": "Barstow",
"san bernardino, ca": "San Bernardino",
"los angeles, ca": "Los Angeles"}
self.start = ListBox()
self.end = ListBox()
for value in places:
self.start.addItem(places[value], value)
self.end.addItem(places[value], value)
self.start.addChangeListener(self.calcRoute)
self.end.addChangeListener(self.calcRoute)
topPanel.add(self.start)
topPanel.add(self.end)
# now, the map
mapPanel = SimplePanel()
mapPanel.setSize('800', '500')
self.add(mapPanel, DockPanel.CENTER)
chigado = LatLng(41.850033, -87.6500523)
options = MapOptions(zoom=7, center=chigado,
mapTypeId=MapTypeId.ROADMAP)
self.map = Map(mapPanel.getElement(), options)
# initialize the renderer
self.directionsDisplay = DirectionsRenderer()
self.directionsDisplay.setMap(self.map)
self.directionsService = DirectionsService()
def calcRoute(self):
start = self.start.getValue(self.start.getSelectedIndex())
end = self.end.getValue(self.end.getSelectedIndex())
print "calcRoute start:", start, "end:", end
request = DirectionsRequest(origin=start, destination=end, \
travelMode=DirectionsTravelMode.DRIVING)
self.directionsService.route(request, self.directionsResult)
def directionsResult(self, response, status):
print "directionsResult:"
if status == DirectionsStatus.OK:
for trip in response.trips:
print "copyrights:", trip.copyrights
for route in trip.routes:
print route.start_geocode.formatted_address
print route.end_geocode.formatted_address
print route.steps[0].start_point
print route.steps[0].end_point
print "\n"
self.directionsDisplay.setDirections(response)
示例3: CompaniesAppGUI
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getValue [as 别名]
class CompaniesAppGUI(AbsolutePanel):
def __init__(self):
AbsolutePanel.__init__(self)
self.app = CompaniesApp()
self.history = []
self.save = Button("save", self)
self.selectDepartment = Button("select", self)
self.selectEmployee = Button("select", self)
self.edit = Button("edit", self)
self.cut = Button("cut", self)
self.back = Button("back", self)
self.name = TextBox()
self.address = TextBox()
self.manager = TextBox()
self.departments = ListBox(Size=("100%"), VisibleItemCount="5")
self.employees = ListBox(Size=("100%"), VisibleItemCount="5")
self.total = TextBox()
self.errors = VerticalPanel()
self.grid = Grid()
self.allPanels = VerticalPanel()
self.allPanels.add(self.grid)
self.allPanels.add(self.errors)
self.add(self.allPanels)
self.initCompanyGUI()
def onClick(self, sender):
self.errors.clear()
if sender == self.cut:
self.current.cut()
self.total.setText(self.current.total())
if sender == self.save:
if self.current.__class__.__name__ == "Employee":
if self.validateEmployee(self.current.id, self.name.getText(), self.address.getText(), self.total.getText()) == True:
self.current.save(self.name.getText(), self.address.getText(), float(self.total.getText()))
else:
if self.validateDepartment(self.current.id, self.name.getText()) == True:
self.current.save(self.name.getText())
if sender == self.selectDepartment:
if (self.departments.getSelectedIndex() > -1):
self.history.append(self.current)
self.current = self.app.getDepartment(self.departments.getValue(self.departments.getSelectedIndex()))
self.initDepartmentGUI()
if sender == self.selectEmployee:
if (self.employees.getSelectedIndex() > -1):
self.history.append(self.current)
self.current = self.app.getEmployee(self.employees.getValue(self.employees.getSelectedIndex()))
self.initEmployeeGUI()
if sender == self.edit:
self.history.append(self.current)
self.current = self.current.getManager()
self.initEmployeeGUI()
if sender == self.back:
if len(self.history) > 0:
self.current = self.history.pop()
if self.current.__class__.__name__ == "Company":
self.initCompanyGUI()
else:
self.initDepartmentGUI()
def validateDepartment(self, index, name):
valid = True
if name == "":
self.errors.add(Label("- Enter a valid name, please."))
valid = False
for item in self.app.departments:
if item.id != index and name == item.name:
self.errors.add(Label("- There is already a department with the same name. Enter a valid name, please."))
valid = False
return valid
def validateEmployee(self, index, name, address, salary):
valid = True
if name == "":
self.errors.add(Label("- Enter a valid name, please."))
valid = False
if address == "":
self.errors.add(Label("- Enter a valid address, please."))
valid = False
if salary == "":
self.errors.add(Label("- Enter a valid salary, please."))
valid = False
try:
float(salary)
except ValueError:
self.errors.add(Label("- The salary must be a number. Enter a valid salary, please."))
valid = False
#.........这里部分代码省略.........