本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.getItemText方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.getItemText方法的具体用法?Python ListBox.getItemText怎么用?Python ListBox.getItemText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.getItemText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ListBoxDemo
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [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: TheoremPanel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [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)
示例3: SaveDialog
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class SaveDialog(DialogWindow):
def __init__(self, theorem, **kwargs):
DialogWindow.__init__(self, modal=True, close=True)
self.theorem=theorem
v = VerticalPanel()
v.setWidth(300)
# v.setHeight(500)
self.setText("save")
self.setPopupPosition(100, 100)
self.setStyleAttribute("background-color", "#ffffff")
self.setStyleAttribute("color", "red")
self.setStyleAttribute("border-width", "5px")
self.setStyleAttribute("border-style", "solid")
self.im=Image()
self.im.setUrl(latex_to_url(self.theorem.formula.to_latex()))
v.add(self.im)
h=HorizontalPanel()
self.radio=RadioButton("group1", "Existing folder:")
h.add(self.radio)
self.list = ListBox()
self.list.setVisibleItemCount(1)
for f in Theorem.get_all_folders():
self.list.addItem(f)
h.add(self.list)
v.add(h)
h=HorizontalPanel()
h.add(RadioButton("group1", "New folder:"))
self.radio.setChecked(True)
self.textbox=TextBox()
h.add(self.textbox)
v.add(h)
v.add(Button("Done",self.done_click))
self.add(v)
def get_folder_name(self):
if self.radio.getChecked():
return self.list.getItemText(self.list.getSelectedIndex())
else:
return self.textbox.getText()
def done_click(self):
self.theorem.folder=self.get_folder_name()
Theorem.theorems.append(self.theorem)
IO.save()
self.hide()
示例4: Projects_Editor
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class Projects_Editor(SimplePanel):
'''
Create and edit projects
'''
def __init__(self):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.hpanel = HorizontalPanel(Width='475px')
self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM)
self.name = TextBox()
self.name.setStyleName('form-control')
self.status = ListBox()
self.status.addItem('Active')
self.status.addItem('Inactive')
self.status.setVisibleItemCount(0)
self.status.setStyleName('form-control input-lg')
self.status.setSize('100px', '34px')
lbl = Label('', Width='10px')
self.add_btn = Button('Add')
self.add_btn.setStyleName('btn btn-primary')
self.del_btn = Button('Delete')
self.del_btn.setStyleName('btn btn-danger')
self.hpanel.add(self.name)
self.hpanel.add(lbl)
self.hpanel.add(self.status)
self.hpanel.add(self.add_btn)
self.hpanel.add(self.del_btn)
def get_name_txt(self):
'''Return project name.
'''
return self.name.getText()
def get_status(self):
'''Return project status.
'''
return self.status.getItemText(self.status.getSelectedIndex())
示例5: RecipeViewer
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class RecipeViewer(Sink):
recipeDict = None
def __init__(self, parent=None):
Sink.__init__(self, parent)
self.RVDock = HorizontalPanel(Spacing=5)
self.RList = ListBox()
self.RList.addClickListener(getattr(self, "onRecipeSelected"))
self.RView = HTML()
HTTPRequest().asyncGet("recipes.xml", RecipeListLoader(self))
self.RVDock.add(self.RList)
self.RVDock.add(self.RView)
self.initWidget(self.RVDock)
def onRecipeSelected(self, item):
recipe = self.RList.getItemText(self.RList.getSelectedIndex())
HTTPRequest().asyncGet("/recipecontent?recipe=%s" % recipe, RecipeViewLoader(self))
def onShow(self):
pass
示例6: Lists
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [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)
示例7: AutoCompleteTextBox
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
#.........这里部分代码省略.........
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):
if self.choices.getItemCount() > 0:
self.setText(self.choices.getItemText(self.choices.getSelectedIndex()))
self.choices.clear()
self.choicesPopup.hide()
self.setFocus(True)
self.visible = False
示例8: __init__
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
#.........这里部分代码省略.........
# For some reason the '0x' at the start of the string is causing exceptions,
# even though it works fine with interactive python. I'll take it off anyway.
string=sender.getText()
if( len(string)>=2 ) :
if string[0]=='0' and string[1]=='x' : string=string[2:]
value=int( string, 16 ) # convert as hex
# Cap values at 255
if value<0 : value=0
if value>255 : value=255
sender.setStyleAttribute( "background-color", "#FFFFFF" )
# Convert to the same format as everything else
sender.setText( "0x%02x"%value )
# Send the change to the RPC service
messageParameters = {}
for cbcName in self.getActiveCBCs() :
messageParameters[cbcName]={ sender.getTitle():value }
self.rpcService.setI2CRegisterValues( messageParameters, I2CPanel.RefreshListener(self) )
except ValueError:
sender.setStyleAttribute( "background-color", "#FF3333" )
#self.echoSelection()
def echoSelection(self): #fb - a good "print screen" method
msg = " File saved: "
for names in self.getCheckedStates():
msg += names
self.echo.setText(msg)
def getList(self):
selectCBCs = []
for i in range(self.cbcList.getItemCount()) :
if self.cbcList.isItemSelected(i):
selectedCBCs.append(self.cbcList.getItemText(i))
def getTotalCBCs(self) : #fb
totalCBCs = []
for i in range(self.cbcList.getItemCount()) :
totalCBCs.append(self.cbcList.getItemText(i))
return totalCBCs
def getSpecificCBC(self, i): #fb
specificCBC = []
specificCBC.append(self.cbcList.getItemText(i))
return specificCBC
def getActiveCBCs(self) :
selectedCBCs = []
for i in range(self.cbcList.getItemCount()) :
if self.cbcList.isItemSelected(i):
selectedCBCs.append(self.cbcList.getItemText(i))
return selectedCBCs
def getCheckedStates(self): # returns the checked boxes + filename
selectedStates = []
#for names in self.stateValueEntries:
#if str(self.stateValueEntries[names].isChecked())=="True":
# selectedStates.append(names)
selectedStates.append(self.saveFileName.getText())
return selectedStates
def createRegisterPanel( self, registerNames ) :
"""
Creates panels and buttons for everything given in registerNames, and returns the main panel.
"""
示例9: Milestones_Row
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class Milestones_Row(SimplePanel):
'''
Create and edit projects
'''
def __init__(self, milestone_names, milestone_dates):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.milestone_dates = milestone_dates
self.hpanel = HorizontalPanel()
self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP)
self.name = ListBox(Height='34px', Width='208px')
self.name.setStyleName('form-control input-lg')
self.name.addChangeListener(getattr(self, 'on_milestone_changed'))
for m in milestone_names:
self.name.addItem(m)
if len(self.milestone_dates) > 0:
self.planned_completion = Label(self.milestone_dates[0])
else:
self.planned_completion = Label('Undefined')
self.planned_completion.setStyleName('form-control text-normal')
self.expected_completion = Report_Date_Field(cal_ID='end')
self.expected_completion.getTextBox().setStyleName('form-control')
self.expected_completion.setRegex(DATE_MATCHER)
self.expected_completion.appendValidListener(self._display_ok)
self.expected_completion.appendInvalidListener(self._display_error)
self.expected_completion.validate(None)
self.hpanel.add(self.name)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.planned_completion)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.expected_completion)
def get_name_txt(self):
'''Return project name.
'''
return self.name.getText()
def get_milestone_data(self):
'''Get milestone data and return in the form suitable for passing to
the model.
'''
name = self.name.getItemText(self.name.getSelectedIndex())
planned_completion = self.planned_completion.getText()
expected_completion = self.expected_completion.getTextBox().getText()
return (name, planned_completion, expected_completion)
def _display_ok(self, obj):
obj.setStyleName('form-input')
def _display_error(self, obj):
if len(obj.getTextBox().getText()) > 0:
obj.setStyleName('form-group has-error')
def on_milestone_changed(self, event):
'''
Change completion date if milestone changed
'''
ind = self.name.getSelectedIndex()
self.planned_completion.setText(self.milestone_dates[ind])
示例10: Impediments
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class Impediments(SimplePanel):
'''
Create and edit projects
'''
def __init__(self, start_date, can_delete=True):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.vpanel = VerticalPanel()
desc_panel = VerticalPanel()
self.desc_box = TextBox()
self.desc_box.setVisibleLength(44)
self.desc_box.setStyleName('form-control')
desc_lbl = Label('impediment description')
desc_lbl.setStyleName('text-muted')
desc_panel.add(self.desc_box)
desc_panel.add(desc_lbl)
# Set to False if loaded from database
self.can_delete = can_delete
status_panel = VerticalPanel()
self.status_lst = ListBox(Height='34px')
self.status_lst.setStyleName('form-control input-lg')
self.status_lst.addItem('Open')
self.status_lst.addItem('Closed')
# we put date here
self.status_lbl = Label('')
self.set_start_date(start_date)
self.status_lbl.setStyleName('text-muted')
status_panel = VerticalPanel()
status_panel.add(self.status_lst)
status_panel.add(self.status_lbl)
self.comment = Text_Area_Row('', 'why it exists or is being closed')
hpanel = HorizontalPanel()
hpanel.add(desc_panel)
hpanel.add(Label(Width='10px'))
hpanel.add(status_panel)
self.vpanel.add(hpanel)
self.vpanel.add(self.comment.panel())
def set_start_date(self, start_date):
date_str = 'added on: ' + start_date
self.status_lbl.setText(date_str)
def get_impediment_data(self):
'''Get impediment data as a list suitable to passing to model.
'''
desc = self.desc_box.getText()
comment = self.comment.widget().getText()
state = self.status_lst.getItemText(self.status_lst.getSelectedIndex())
lbl_text = self.status_lbl.getText()
#
ind = lbl_text.find(':') + 1
# We need just date
start_date = lbl_text[ind:].strip()
if state == 'Open':
end_date = None
else:
end_date = datetime.date.today().strftime('%d/%m/%Y')
return (desc, comment, start_date, end_date, state)
示例11: Milestones_Editor
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class Milestones_Editor(SimplePanel):
'''
Create and edit projects
'''
def __init__(self):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.hpanel = HorizontalPanel(Width='755px')
self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP)
self.name = TextBox()
self.name.setStyleName('form-control')
self.start = Report_Date_Field(cal_ID='start')
self.start.getTextBox().setStyleName('form-control')
self.start.setRegex(DATE_MATCHER)
self.start.appendValidListener(self._display_ok)
self.start.appendInvalidListener(self._display_error)
self.start.validate(None)
self.end = Report_Date_Field(cal_ID='end')
self.end.getTextBox().setStyleName('form-control')
self.end.setRegex(DATE_MATCHER)
self.end.appendValidListener(self._display_ok)
self.end.appendInvalidListener(self._display_error)
self.end.validate(None)
self.status = ListBox()
self.status.addItem('Active')
self.status.addItem('Inactive')
self.status.setVisibleItemCount(0)
self.status.setStyleName('form-control input-lg')
self.status.setSize('100px', '34px')
spacer1 = Label(Width='10px')
spacer2 = Label(Width='10px')
spacer3 = Label(Width='10px')
self.add_btn = Button('Add')
self.add_btn.setStyleName('btn btn-primary')
self.del_btn = Button('Delete')
self.del_btn.setStyleName('btn btn-danger')
self.hpanel.add(self.name)
self.hpanel.add(spacer1)
self.hpanel.add(self.status)
self.hpanel.add(spacer2)
self.hpanel.add(self.start)
#self.hpanel.add(spacer3)
self.hpanel.add(self.end)
self.hpanel.add(self.add_btn)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.del_btn)
def get_name_txt(self):
'''Return project name.
'''
return self.name.getText()
def get_status(self):
'''Return project status.
'''
return self.status.getItemText(self.status.getSelectedIndex())
def get_milestone_data(self):
'''Return all data for a milestone and validation result.
'''
valid = False
name_txt = self.get_name_txt()
status_txt = self.get_status()
start_txt = self.start.getTextBox().getText()
end_txt = self.end.getTextBox().getText()
data = [name_txt, status_txt, start_txt, end_txt]
# We are only valid if these conditions are met
if len(name_txt.strip()) > 0 and self.start.valid == True and self.end.valid == True:
valid = True
return (valid, data)
def _display_ok(self, obj):
obj.setStyleName('form-input')
def _display_error(self, obj):
if len(obj.getTextBox().getText()) > 0:
obj.setStyleName('form-group has-error')
示例12: ReducePanelIFACE
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class ReducePanelIFACE(PanelIFACE):
def __init__(self, parent = None):
PanelIFACE.__init__(self, parent)
self.panel = VerticalPanel()
self.panel.setBorderWidth(1)
self.panel.setWidth("100%")
# prepare panel
self.prepareReduce = HTML("<tt> .. none yet .. </tt>", True, )
self.recipeList = ListBox()
self.recipeList.addChangeListener(getattr(self, "onRecipeSelected"))
self.recipeList.addItem("None")
HTTPRequest().asyncGet("recipes.xml",
RecipeListLoader(self))
#EO prepare panel
self.reduceCLPanel = DockPanel(Spacing = 5)
self.reduceCLPanel.add(HTML("<i>Reduce Command Line</i>:"), DockPanel.NORTH)
self.reduceCLPanel.add(self.prepareReduce, DockPanel.NORTH)
self.reduceFilesPanel = DockPanel(Spacing = 5)
self.reduceFilesPanel.add(HTML("<b>Datasets</b>:"), DockPanel.WEST)
self.reduceFiles = ListBox()
self.reduceFiles.setVisibleItemCount(5)
self.reduceFilesPanel.add(self.reduceFiles, DockPanel.WEST)
self.clearReduceFilesButton = Button("<b>Clear List</b>", listener = getattr(self, "onClearReduceFiles"))
self.reduceFilesPanel.add(self.clearReduceFilesButton, DockPanel.SOUTH)
self.recipeListPanel = DockPanel(Spacing = 5)
self.recipeListPanel.add(HTML("<b>Recipes List</b>:"),DockPanel.WEST)
self.recipeListPanel.add(self.recipeList, DockPanel.WEST)
self.runReduceButton = Button("<b>RUN REDUCE</b>", listener = getattr(self, "onRunReduce"))
self.adInfo = HTML("file info...")
# major sub panels
self.panel.add(self.reduceCLPanel)
self.panel.add(self.reduceFilesPanel)
self.panel.add(self.recipeListPanel)
self.panel.add(self.runReduceButton)
self.panel.add(self.adInfo)
def onRecipeSelected(self, event):
self.updateReduceCL()
def onClearReduceFiles(self, event):
self.reduceFiles.clear()
self.adInfo.setHTML("file info...")
self.updateReduceCL()
def updateReduceCL(self):
recipe = self.recipeList.getItemText(self.recipeList.getSelectedIndex())
if recipe=="None":
rstr = ""
else:
rstr = "-r "+recipe
rfiles = []
for i in range(0, self.reduceFiles.getItemCount()):
fname = self.reduceFiles.getItemText(i)
rfiles.append(fname)
filesstr = " ".join(rfiles)
self.prepareReduce.setHTML('<b>reduce</b> %(recipe)s %(files)s' %
{ "recipe":rstr,
"files":filesstr})
def onRunReduce(self):
recipe = self.recipeList.getItemText(self.recipeList.getSelectedIndex())
if recipe=="None":
rstr = ""
else:
rstr = "p=-r"+recipe
rfiles = []
for i in range(0, self.reduceFiles.getItemCount()):
fname = self.reduceFiles.getItemText(i)
rfiles.append(quote(self.pathdict[fname]["path"]))
filesstr = "&p=".join(rfiles)
cl = "/runreduce?%s&p=%s" % (rstr, filesstr)
# @@TEST
# cl = "/recipes.xml"
if False:
msg = repr(self.parent)+repr(dir(self.parent))
JS("alert(msg)")
if hasattr(self.parent, "roFrame"):
self.parent.roFrame.setUrl(cl)
self.parent.tabPanel.selectTab(self.parent.tabIFACEdict["rogui"])
else:
JS("window.open(cl)")
def onTreeItemSelected(self, item):
pathdict = self.pathdict
tfile = item.getText()
#check if already in
#.........这里部分代码省略.........
示例13: Trees
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [as 别名]
class Trees(Sink):
pathdict = {}
reduceFiles = None
def __init__(self, parent = None):
Sink.__init__(self, parent)
self.reduceFiles = []
if True:
HTTPRequest().asyncGet("datadir.xml",
DirDictLoader(self),
)
dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT,
Spacing=10,
Size=("100%","100%"))
self.dock = dock
self.fProto = []
self.fTree = Tree()
self.prPanel = VerticalPanel(Size=("50%", ""))
self.treePanel = HorizontalPanel(Size=("50%", "100%"))
self.treePanel.add(self.fTree)
dock.add(self.treePanel, DockPanel.WEST)
self.treePanel.setBorderWidth(1)
self.treePanel.setWidth("100%")
self.prPanel.setBorderWidth(1)
self.prPanel.setWidth("100%")
# prepare panel
self.prepareReduce = HTML("<tt> .. none yet .. </tt>", True, )
self.recipeList = ListBox()
self.recipeList.addChangeListener(getattr(self, "onRecipeSelected"))
self.recipeList.addItem("None")
HTTPRequest().asyncGet("recipes.xml",
RecipeListLoader(self))
#EO prepare panel
self.reduceCLPanel = DockPanel(Spacing = 5)
self.reduceCLPanel.add(HTML("<i>Reduce Command Line</i>:"), DockPanel.NORTH)
self.reduceCLPanel.add(self.prepareReduce, DockPanel.NORTH)
self.reduceFilesPanel = DockPanel(Spacing = 5)
self.reduceFilesPanel.add(HTML("<b>Datasets</b>:"), DockPanel.WEST)
self.reduceFiles = ListBox()
self.reduceFiles.setVisibleItemCount(5)
self.reduceFilesPanel.add(self.reduceFiles, DockPanel.WEST)
self.clearReduceFilesButton = Button("<b>Clear List</b>", listener = getattr(self, "onClearReduceFiles"))
self.reduceFilesPanel.add(self.clearReduceFilesButton, DockPanel.SOUTH)
self.recipeListPanel = DockPanel(Spacing = 5)
self.recipeListPanel.add(HTML("<b>Recipes List</b>:"),DockPanel.WEST)
self.recipeListPanel.add(self.recipeList, DockPanel.WEST)
self.runReduceButton = Button("<b>RUN REDUCE</b>", listener = getattr(self, "onRunReduce"))
self.adInfo = HTML("file info...")
# major sub panels
self.prPanel.add(self.reduceCLPanel)
self.prPanel.add(self.reduceFilesPanel)
self.prPanel.add(self.recipeListPanel)
self.prPanel.add(self.runReduceButton)
self.prPanel.add(self.adInfo)
dock.add(self.prPanel,DockPanel.EAST)
dock.setCellWidth(self.treePanel, "50%")
dock.setCellWidth(self.prPanel, "50%")
for i in range(len(self.fProto)):
self.createItem(self.fProto[i])
self.fTree.addItem(self.fProto[i].item)
self.fTree.addTreeListener(self)
self.initWidget(self.dock)
if False: #self.parent.filexml != None:
DirDictLoader(self).onCompletion(self.parent.filexml)
def onTreeItemSelected(self, item):
pathdict = self.pathdict
tfile = item.getText()
#check if already in
for i in range(0, self.reduceFiles.getItemCount()):
fname = self.reduceFiles.getItemText(i)
if fname == tfile:
return
self.reduceFiles.addItem(tfile)
self.updateReduceCL()
filename = tfile
if filename in pathdict:
if pathdict[filename]["filetype"] == "fileEntry":
HTTPRequest().asyncGet("adinfo?filename=%s" % self.pathdict[item.getText()]["path"],
ADInfoLoader(self),
)
else:
self.adInfo.setHTML("""
<b style="font-size:200%%">%s</b>""" % pathdict[filename]["filetype"])
#.........这里部分代码省略.........
示例14: DisplayHistogramsView
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import getItemText [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 )