本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.addChangeListener方法的具体用法?Python ListBox.addChangeListener怎么用?Python ListBox.addChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.addChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ListBoxDemo
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
class ListBoxDemo(SimplePanel):
def __init__(self):
SimplePanel.__init__(self)
hPanel = HorizontalPanel()
hPanel.setSpacing(10)
self.list1 = ListBox()
self.list1.setVisibleItemCount(10)
self.list1.addItem("Item 1")
self.list1.addItem("Item 2")
self.list1.addItem("Item 3")
self.list1.addChangeListener(getattr(self, "onList1ItemSelected"))
self.list2 = ListBox()
self.list2.setVisibleItemCount(1)
self.list2.addItem("Item A")
self.list2.addItem("Item B")
self.list2.addItem("Item C")
self.list2.addChangeListener(getattr(self, "onList2ItemSelected"))
hPanel.add(self.list1)
hPanel.add(self.list2)
self.add(hPanel)
def onList1ItemSelected(self, event):
item = self.list1.getItemText(self.list1.getSelectedIndex())
Window.alert("You selected " + item + " from list 1")
def onList2ItemSelected(self, event):
item = self.list2.getItemText(self.list2.getSelectedIndex())
Window.alert("You selected " + item + " from list 2")
示例2: makeFileChooser
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def makeFileChooser():
l = ListBox()
for i, tup in enumerate(files):
name, content = tup
l.addItem(name, i)
l.addChangeListener(loadFile)
return l
示例3: TheoremPanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
class TheoremPanel(ScrollPanel):
def __init__(self, after):
ScrollPanel.__init__(self, Size=("630px", "500px"))
self.after = after
self.pok = VerticalPanel()
self.add(self.pok)
self.images = list()
def onItemSelected():
item = self.list2.getItemText(self.list2.getSelectedIndex())
self.refresh_theorems(item)
self.list2 = ListBox()
self.list2.setVisibleItemCount(1)
for f in Theorem.get_all_folders():
self.list2.addItem(f)
self.pok.add(self.list2)
self.list2.addChangeListener(onItemSelected)
self.refresh_theorems(self.list2.getItemText(self.list2.getSelectedIndex()))
def remove_images(self):
for im in self.images:
self.pok.remove(im)
self.images = list()
def refresh_theorems(self, folder):
self.remove_images()
def onClick(theorem):
def name(n):
return "var" + str(n + 1)
def print_scheme(n):
return ["\\alpha", "\\beta", "\\gamma", "\\delta", "\\epsilon"][n]
def poas(sender):
if len(theorem.operations) == 1:
constants = [Operation("const" + str(i + 1), 0, print_scheme(i), name(i), Operation.EXPRESSION)
for i in range(theorem.operations[0].no_of_args)]
def after1(f):
self.after(
theorem.formula.substitute_definition(Formula([theorem.operations[0]] + constants), f),
predecessors=[], rule_name="insert")
request_formula([op for op in proof.get_operations()] + constants,
after1, type=('rel' if theorem.operations[0].type == Operation.RELATION else 'exp'))
else:
self.after(theorem.formula, predecessors=[], rule_name="insert")
return poas
for ax in [x for x in Theorem.theorems if x.folder == folder]:
im = Image()
im.addClickListener(onClick(ax))
im.setUrl(latex_to_url(ax.formula.to_latex()))
self.pok.add(im)
self.images.append(im)
示例4: createColorList
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def createColorList(self, caption):
lb = ListBox()
lb.addChangeListener(self)
lb.setVisibleItemCount(1)
lb.addItem(caption)
lb.addItem("White", "white")
lb.addItem("Black", "black")
lb.addItem("Red", "red")
lb.addItem("Green", "green")
lb.addItem("Yellow", "yellow")
lb.addItem("Blue", "blue")
return lb
示例5: createHeadingStyleList
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def createHeadingStyleList(self, caption):
lb = ListBox()
lb.addChangeListener(self)
lb.setVisibleItemCount(1)
lb.addItem(caption)
lb.addItem("Heading1", "h1")
lb.addItem("Heading2", "h2")
lb.addItem("Heading3", "h3")
lb.addItem("Heading4", "h4")
lb.addItem("Heading5", "h5")
return lb
示例6: createFontSizes
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def createFontSizes(self):
lb = ListBox()
lb.addChangeListener(self)
lb.setVisibleItemCount(1)
lb.addItem("Size")
lb.addItem("XXsmall")
lb.addItem("Xsmall")
lb.addItem("small")
lb.addItem("medium")
lb.addItem("large")
lb.addItem("Xlarge")
lb.addItem("XXlarge")
return lb
示例7: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def onModuleLoad(self):
'''Create initial view of the panel.
'''
# Container that keeps everything
self.panel = VerticalPanel()
self.panel.setSpacing(10)
# Create list of projects
proj_list = ListBox(Height='34px')
proj_list.addItem('')
proj_list.setVisibleItemCount(0)
proj_list.addChangeListener(getattr(self, 'on_project_changed'))
proj_list.setStyleName('form-control input-lg')
self.proj_row = Form_Row('Select project',
proj_list,
help='project, status of which you want to report')
# Project-specific container
self.project_panel = VerticalPanel()
# Submit report button
self.submit_btn = Button('Submit report', getattr(self, 'send_data'))
self.submit_btn.setStyleName('btn btn-primary btn-lg')
self.submit_btn.setEnabled(False)
self.msg_lbl = HTMLPanel('', Width='475px')
# Add controls here
self.panel.add(self.proj_row.panel())
self.panel.add(self.project_panel)
self.panel.add(Label(Height='20px'))
self.panel.add(self.msg_lbl)
btn_holder = HorizontalPanel()
btn_holder.add(self.submit_btn)
help_btn = HTMLPanel('')
help_btn.setHTML(MODAL_PNL)
btn_holder.add(Label(Width='10px'))
btn_holder.add(help_btn)
self.panel.add(btn_holder)
self.root = RootPanel('report')
self.root.add(self.panel)
示例8: createFontList
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def createFontList(self):
lb = ListBox()
lb.addChangeListener(self)
lb.setVisibleItemCount(1)
lb.addItem("Font", "")
lb.addItem("Normal", "")
lb.addItem("Times New Roman", "Times New Roman")
lb.addItem("Arial", "Arial")
lb.addItem("Aramanth", "Aramanth")
lb.addItem("Calibri", "Calibri")
lb.addItem("Courier New", "Courier New")
lb.addItem("Georgia", "Georgia")
lb.addItem("Helvetica", "Helvetica")
lb.addItem("Symbol", "Symbol")
lb.addItem("Trebuchet", "Trebuchet")
lb.addItem("Verdana", "Verdana")
return lb
示例9: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def onModuleLoad(self):
self.layout = HorizontalPanel()
# Each demo will set their own dimensions, so it doesn't matter
# what we initialize the canvas to.
canvas = GWTCanvas(400,400)
canvas.addStyleName("gwt-canvas")
self.demos = []
# Create demos
self.demos.append(StaticDemo(canvas))
self.demos.append(LogoDemo(canvas))
self.demos.append(ParticleDemo(canvas))
self.demos.append(GradientDemo(canvas))
self.demos.append(SuiteDemo(canvas))
# Add them to the selection list box
lb = ListBox()
lb.setStyleName("listBox")
for i in range(len(self.demos)):
lb.addItem(self.demos[i].getName())
lb.addChangeListener(self)
# start off with the first demo
self.currentDemo = self.demos[0]
# Add widgets to self.layout and RootPanel
vp = VerticalPanel()
vp.add(lb)
vp.add(canvas)
self.layout.add(vp)
if self.currentDemo.getControls() is not None:
self.layout.add(self.currentDemo.getControls())
RootPanel().add(self.layout)
self.currentDemo.drawDemo()
示例10: UserForm
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [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):
#.........这里部分代码省略.........
示例11: MechOptionPanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
class MechOptionPanel(HorizontalPanel):
def __init__(self, handle, idx, checkOptions = [False, True]):
HorizontalPanel.__init__(self)
self.log = logging.getConsoleLogger(type(self).__name__, lev)
self.log.disabled = False
self.log.debug('__init__: Instantiation')
self.idx = idx
self._handle = handle
self._checkOptions = checkOptions
self.setStyleName('os-mech-checkbox-options')
#checkbox = CheckBox('symbol')
#checkbox.setChecked(checkOptions[0])
#checkbox.addClickListener(self.onClickOption)
#checkbox.setID('CBSY%d'%idx)
#self.append(checkbox)
#checkbox = CheckBox('value')
#checkbox.setChecked(checkOptions[1])
#checkbox.addClickListener(self.onClickOption)
#checkbox.setID('CBVA%d'%idx)
#self.append(checkbox)
self._textBoxRatio = TextBox('1:1')
self._ratioCache = self._textBoxRatio.getText()
self._textBoxRatio.setTitle('Ratio')
self._ratioCache = self._textBoxRatio.getText()
self._textBoxRatio.addChangeListener(self.onRatioChange)
self._textBoxRatio.setID('TXRT%d'%idx)
self._textBoxRatio.setStyleName('os-mech-textbox-ratio')
self._listBoxSize = ListBox()
self._listBoxSize.addChangeListener(self.onSizeSet)
self._listBoxSize.setVisibleItemCount(1)
self._listBoxSize.setStyleName('os-mech-listbox-size')
self._listBoxUnit = ListBox()
self._listBoxUnit.addChangeListener(self.onUnitSet)
self._listBoxUnit.setVisibleItemCount(1)
self._listBoxUnit.setStyleName('os-mech-listbox-unit')
self.append(Label('Ratio'))
self.append(self._textBoxRatio)
self.append(Label('Size'))
self.append(self._listBoxSize)
self.append(Label('Unit'))
self.append(self._listBoxUnit)
def onSizeSet(self, sender, event):
value = sender.getSelectedItemText()[0]
self.log.debug('Change size to %s'%value)
self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'size', value)
def onUnitSet(self, sender, event):
value = sender.getSelectedValues()[0]
self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'unit',int(value))
def onRatioChange(self, sender, event):
#validate ratio change
matches = re.findall(r'^\d{1,4}:\d{1,4}$', self._textBoxRatio.getText())
if len(matches) == 1: # correct
self._ratioCache = self._textBoxRatio.getText()
self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'ratio', self._ratioCache)
else: # invalid
self._textBoxRatio.setText(self._ratioCache)
def actSizeFill(self, options, value = 0):
for idx, option in enumerate(options, idx):
self._listBoxSize.addItem(option, idx)
self._listBoxSize.setSelectedIndex(value)
def actUnitFill(self, options, value = 0):
for number, name in options.items():
self._listBoxUnit.addItem(name, number)
if value < 100000:
self._listBoxUnit.setSelectedIndex(value)
else:
self._listBoxUnit.selectValue(value)
def actSizeSet(self, value):
self.log.debug('actSizeSet, setting value %s'%value)
self._listBoxSize.selectValue(value)
def actRatioChange(self, ratio):
self._textBoxRatio.setText(ratio)
self._ratioCache = ratio
def onClickOption(self, sender, event):
sendId = int(sender.getID()[4:])
if sendId == 0:
self._checkOptions[0] = sender.isChecked()
self._checkOptions[1] = not(sender.isChecked())
else:
self._checkOptions[0] = not(sender.isChecked())
self._checkOptions[1] = sender.isChecked()
checkbox = self.getWidget(0)
checkbox.setChecked(self._checkOptions[0])
checkbox = self.getWidget(1)
checkbox.setChecked(self._checkOptions[1])
self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'checkOptions', self._checkOptions)
示例12: onRemoteResponse
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
def onRemoteResponse(self, response, request_info):
mname = request_info.method
if mname == "customize_message":
showCustomizationResult(self, response, request_info)
return
if mname == "get_messagesdata_for_cust":
locations_data = response["locations"]
selectionbox = VerticalPanel(Padding=3)
locations = ListBox()
for (loc_name, loc_id) in locations_data:
locations.addItem(loc_id, loc_name)
messages = ListBox()
messages.setName("locations")
messages.addItem(location_select_label)
for (name, d) in response["messages"].items():
messages.addItem(d['label'], name)
locations.addChangeListener(self)
messages.addChangeListener(self)
self.locations = locations
self.messages = messages
locationbox = HorizontalPanel()
locationbox.add(Label("Location: ", StyleName="text", Width=80))
locationbox.add(locations)
msgnamebox = HorizontalPanel()
msgnamebox.add(Label("Message: ", StyleName="text", Width=80))
msgnamebox.add(messages)
selectionbox.add(locationbox)
selectionbox.add(msgnamebox)
mainpanel = VerticalPanel(StyleName="dataBoxContent")
mainpanel.add(selectionbox)
self.mainpanel = mainpanel
root = RootPanel()
root.add(mainpanel)
if mname == "get_messagecustdata":
self.messages_data = response
buttonspanel = FlowPanel(Spacing=1, Padding=1, Width=600)
#buttonspanel.add(Label("Macros:", StyleName="text"))
for macro_d in self.messages_data['macros']:
macrobutton = Button(macro_d['label'], self, StyleName="buttonlikelink")#"nicebutton small")
macrobutton.name = macro_d['name']
buttonspanel.add(macrobutton)
msgpanel = VerticalPanel(Padding=1, Spacing=1)
messagebox = TextArea()
messagebox.setCharacterWidth(70)
height = len(self.messages_data["text"].split('\n')) + 1
messagebox.setVisibleLines(height)
messagebox.setText(self.messages_data["text"])
messagebox.setName("textBoxFormElement")
self.messagebox = messagebox
msgpanel.add(messagebox)
self.statusbar = Label(StyleName="errorMessage")
msgpanel.add(self.statusbar)
actionbuttons = HorizontalPanel(Spacing=2)
updatebutton = Button("Update", self, StyleName="nicebutton small yellow")
updatebutton.name = "update"
actionbuttons.add(updatebutton)
#actionbuttons.add(Button("Send me a preview mail"))
msgpanel.add(actionbuttons)
editorbox = VerticalPanel(Padding=1)
editorbox.add(buttonspanel)
editorbox.add(msgpanel)
editorpanel = CaptionPanel("Message editor", editorbox, Padding=1, StyleName="text")
editorpanel.name = "editorpanel"
self.editorpanel = editorpanel
self.mainpanel.add(editorpanel)
示例13: AutoCompleteTextBox
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [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):
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [as 别名]
class SongFrequency:
def __init__(self):
self.artist =''
self.start_date = ''
self.end_date = ''
self.period_search =''
self.search_option = 1
#declare the general interface widgets
self.panel = DockPanel(StyleName = 'background')
self.ret_area = TextArea()
self.ret_area.setWidth("350px")
self.ret_area.setHeight("90px")
self.options = ListBox()
self.search_button = Button("Search", getattr(self, "get_result"), StyleName = 'button')
#set up the date search panel; it has different text boxes for
#to and from search dates
self.date_search_panel = VerticalPanel()
self.date_search_start = TextBox()
self.date_search_start.addInputListener(self)
self.date_search_end = TextBox()
self.date_search_end.addInputListener(self)
self.date_search_panel.add(HTML("Enter as month/day/year", True, StyleName = 'text'))
self.date_search_panel.add(HTML("From:", True, StyleName = 'text'))
self.date_search_panel.add(self.date_search_start)
self.date_search_panel.add(HTML("To:", True, StyleName = 'text'))
self.date_search_panel.add(self.date_search_end)
#set up the artist search panel
self.artist_search = TextBox()
self.artist_search.addInputListener(self)
self.artist_search_panel = VerticalPanel()
self.artist_search_panel.add(HTML("Enter artist's name:",True,
StyleName = 'text'))
self.artist_search_panel.add(self.artist_search)
#Put together the list timespan search options
self.period_search_panel = VerticalPanel()
self.period_search_panel.add(HTML("Select a seach period:",True,
StyleName = 'text'))
self.period_search = ListBox()
self.period_search.setVisibleItemCount(1)
self.period_search.addItem("last week")
self.period_search.addItem("last month")
self.period_search.addItem("last year")
self.period_search.addItem("all time")
self.period_search_panel.add(self.period_search)
#add the listeners to the appropriate widgets
self.options.addChangeListener(self)
self.period_search.addChangeListener(self)
self.ret_area_scroll = ScrollPanel()
self.search_panel = HorizontalPanel()
self.options_panel = VerticalPanel()
# A change listener for the boxes
def onChange(self, sender):
#switch the list box options
if sender == self.options:
self.search_panel.remove(self.period_search_panel)
self.search_panel.remove(self.date_search_panel)
self.search_panel.remove(self.artist_search_panel)
index = self.options.getSelectedIndex()
if index == 0:
self.search_panel.add(self.artist_search_panel)
self.search_option = 1
elif index == 1:
self.search_panel.add(self.date_search_panel)
self.search_option = 2
elif index == 2:
self.search_panel.add(self.period_search_panel)
self.search_option = 3
elif sender == self.period_search:
index = self.period_search.getSelectedIndex()
if index == 0:
self.period_search = "last week"
elif index == 1:
self.period_search = "last month"
elif index == 2:
self.period_search = "last year"
elif index == 3:
self.period_search = "all time"
#A listener for the text boxes
def onInput(self, sender):
if sender == self.artist_search:
self.artist = sender.getText()
elif sender == self.date_search_end:
self.end_date = sender.getText()
elif sender == self.date_search_start:
self.start_date = sender.getText()
#A listener for the buttons that, when the button is clicked, looks up the results and outputs them
def get_result(self):
return_str = " "
if self.search_option == 1:
#.........这里部分代码省略.........
示例15: RolePanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeListener [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