本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.addItem方法的具体用法?Python ListBox.addItem怎么用?Python ListBox.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: editMovieButton_Click
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
def editMovieButton_Click(sender):
# Add textboxes and listbox
editMovieButton.setVisible(False)
cancelButton.setVisible(True)
saveButton.setVisible(True)
editCategory = TextBox()
editName = TextBox()
editRating = ListBox(False)
for i in range(self.MAX_RATING + 1):
editRating.addItem(str(i))
# Variable width textboxes
catlen = len(movie.category)
namelen = len(movie.name)
if (catlen > 8):
editCategory.setWidth(str(catlen*10) + "px")
else:
editCategory.setWidth("80px")
if (namelen > 8):
editName.setWidth(str(namelen*10) + "px")
else:
editName.setWidth("80px")
self.moviesFlexTable.setWidget(row, 1, editCategory)
self.moviesFlexTable.setWidget(row, 2, editName)
self.moviesFlexTable.setWidget(row, 3, editRating)
editCategory.setText(movie.category)
editName.setText(movie.name)
editRating.setSelectedIndex(movie.rating)
示例2: makeFileChooser
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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 addItem [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: SelectionBox
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
class SelectionBox(HorizontalPanel):
"""
This is a text box with the corresponding word that is to be normalized
"""
def __init__(self, token_index, target_word, options):
HorizontalPanel.__init__(self)
self.token_index = token_index
self.table = FlexTable()
self.label = Label(target_word + ":\t")
self.dropdown = ListBox()
for option in options:
self.dropdown.addItem(option)
self.add(self.label)
self.add(self.dropdown)
示例5: ListBoxDemo
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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")
示例6: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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)
示例7: SaveDialog
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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()
示例8: __init__
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
def __init__(self):
Sink.__init__(self)
self.fDialogButton = Button("Show Dialog", self)
self.fPopupButton = Button("Show Popup", self)
panel = VerticalPanel()
panel.add(self.fPopupButton)
panel.add(self.fDialogButton)
list = ListBox()
list.setVisibleItemCount(5)
for i in range(10):
list.addItem("list item %d" % i)
panel.add(list)
panel.setSpacing(8)
self.initWidget(panel)
示例9: make_panel
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
def make_panel(self):
duration = ListBox()
duration.setVisibleItemCount(1)
choices = [ 1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60 ]
for seconds in choices:
duration.addItem(
'%ds' % seconds if seconds < 60 else '%dm' % (seconds / 60),
seconds)
duration.setSelectedIndex(2)
button = Button('test')
handler = TestHandler(duration)
button.addClickListener(handler.func)
panel = HorizontalPanel()
panel.add(duration)
panel.add(button)
return panel
示例10: Projects_Editor
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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())
示例11: createHeadingStyleList
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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
示例12: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
def onModuleLoad(self):
# Create a FormPanel and point it at a service.
self.form = FormPanel()
self.form.setAction("/chat-service/test/")
# Because we're going to add a FileUpload widget, we'll need to set the
# form to use the POST method, and multipart MIME encoding.
self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
self.form.setMethod(FormPanel.METHOD_POST)
# Create a panel to hold all of the form widgets.
panel = VerticalPanel()
self.form.setWidget(panel)
# Create a TextBox, giving it a name so that it will be submitted.
self.tb = TextBox()
self.tb.setName("textBoxFormElement")
panel.add(self.tb)
# Create a ListBox, giving it a name and some values to be associated with
# its options.
lb = ListBox()
lb.setName("listBoxFormElement")
lb.addItem("foo", "fooValue")
lb.addItem("bar", "barValue")
lb.addItem("baz", "bazValue")
panel.add(lb)
# Create a FileUpload widget.
upload = FileUpload()
upload.setName("uploadFormElement")
panel.add(upload)
# Add a 'submit' button.
panel.add(Button("Submit", self))
# Add an event handler to the form.
self.form.addFormHandler(self)
RootPanel().add(self.form)
示例13: onModuleLoad
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [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()
示例14: __init__
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
def __init__(self, autoHide=None, modal=True, **kwargs):
PopupPanel.__init__(self, autoHide, modal, **kwargs)
datasource = None
id = None
if kwargs.has_key("datasrc"):
datasource = kwargs["datasrc"]
if kwargs.has_key("id"):
id = kwargs["id"]
self.setSize(Window.getClientWidth() - 50, Window.getClientHeight() - 50)
self.setPopupPosition(20, 0)
DOM.setAttribute(self, "align", "center")
# self.dbProxInstrucao = DialogBox()
# self.dbProxInstrucao.setHTML("Alow")
# botton = Button("Ok")
# botton.addClickListener(self.onCloseDialog)
# self.dbProxInstrucao.setWidget(botton)
self.caption = HTML()
self.child = None
self.setHTML("<b>Soma de Matrizes.</b>")
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.imageFechar = Image("images/fechar.gif", Size=("32px", "32px"), StyleName="gwt-ImageButton")
self.imgbtnDesfazer = Image("images/previous-arrow.png", Size=("32px", "20px"), StyleName="gwt-ImageButton")
self.imgbtnFazer = Image("images/next-arrow.png", Size=("32px", "20px"), StyleName="gwt-ImageButton")
# self.imgbtnDesfazer.addClickListener(desfazerProxOperacao)
# self.imgbtnFazer.addClickListener(fazerProxOperacao)
self.btnAutomatic = Button("Automático", self.onIniciarAnimacaoAutomatica)
self.btnInterativo = Button("Interativo")
if id == "escalar":
self.btnStepByStep = Button("Passo a passo", IniciarAnimacaoPassoAPasso)
else:
self.btnStepByStep = Button("Passo a passo", self.onIniciarAnimacaoPassoAPasso)
self.btnFazer = Button("fazer >>", fazerProxOperacao)
# self.btnFazer.setEnabled(False);
self.btnDesfazer = Button("<< desfazer", desfazerProxOperacao)
# self.btnDesfazer.setEnabled(False);
self.btnFechar = PushButton(imageFechar, imageFechar)
self.btnTestarResposta = Button("Testar Solução")
self.lbVelocidade = ListBox()
self.lbVelocidade.setID("lbseg")
self.lbVelocidade.addItem("0.5 segundo", value=2)
self.lbVelocidade.addItem("1 segundo", value=1)
self.lbVelocidade.addItem("2 segundos", value=0.5)
self.lbVelocidade.addItem("3 segundos", value=1 / 3)
self.lbVelocidade.addItem("4 segundos", value=0.25)
self.lbVelocidade.addItem("5 segundos", value=0.20)
self.lbVelocidade.addItem("6 segundos", value=0.167)
self.lbVelocidade.addItem("7 segundos", value=0.143)
self.lbVelocidade.addItem("8 segundos", value=0.125)
self.lbVelocidade.addItem("10 segundos", value=0.1)
lblinha1 = ListBox()
lblinha1.setID("lm1")
lblinha1.addItem("1", value=1)
lblinha1.addItem("2", value=2)
lblinha1.addItem("3", value=3)
lblinha1.addItem("4", value=4)
lblinha1.addItem("5", value=5)
lblinha2 = ListBox()
lblinha2.setID("lm2")
lblinha2.addItem("1", value=1)
lblinha2.addItem("2", value=2)
lblinha2.addItem("3", value=3)
lblinha2.addItem("4", value=4)
lblinha2.addItem("5", value=5)
lbcoluna1 = ListBox()
lbcoluna1.setID("cm1")
lbcoluna1.addItem("1", value=1)
lbcoluna1.addItem("2", value=2)
lbcoluna1.addItem("3", value=3)
lbcoluna1.addItem("4", value=4)
lbcoluna1.addItem("5", value=5)
lbcoluna1.addItem("6", value=6)
lbcoluna1.addItem("7", value=7)
lbcoluna2 = ListBox()
lbcoluna2.setID("cm2")
lbcoluna2.addItem("1", value=1)
lbcoluna2.addItem("2", value=2)
lbcoluna2.addItem("3", value=3)
lbcoluna2.addItem("4", value=4)
lbcoluna2.addItem("5", value=5)
lbcoluna2.addItem("6", value=6)
lbcoluna2.addItem("7", value=7)
self.lblStatus = Label("Label para Status")
#.........这里部分代码省略.........
示例15: PopupPagina
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addItem [as 别名]
class PopupPagina(PopupPanel):
def __init__(self, autoHide=None, modal=True, **kwargs):
PopupPanel.__init__(self, autoHide, modal, **kwargs)
datasource = None
id = None
if kwargs.has_key("datasrc"):
datasource = kwargs["datasrc"]
if kwargs.has_key("id"):
id = kwargs["id"]
self.setSize(Window.getClientWidth() - 50, Window.getClientHeight() - 50)
self.setPopupPosition(20, 0)
DOM.setAttribute(self, "align", "center")
# self.dbProxInstrucao = DialogBox()
# self.dbProxInstrucao.setHTML("Alow")
# botton = Button("Ok")
# botton.addClickListener(self.onCloseDialog)
# self.dbProxInstrucao.setWidget(botton)
self.caption = HTML()
self.child = None
self.setHTML("<b>Soma de Matrizes.</b>")
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.imageFechar = Image("images/fechar.gif", Size=("32px", "32px"), StyleName="gwt-ImageButton")
self.imgbtnDesfazer = Image("images/previous-arrow.png", Size=("32px", "20px"), StyleName="gwt-ImageButton")
self.imgbtnFazer = Image("images/next-arrow.png", Size=("32px", "20px"), StyleName="gwt-ImageButton")
# self.imgbtnDesfazer.addClickListener(desfazerProxOperacao)
# self.imgbtnFazer.addClickListener(fazerProxOperacao)
self.btnAutomatic = Button("Automático", self.onIniciarAnimacaoAutomatica)
self.btnInterativo = Button("Interativo")
if id == "escalar":
self.btnStepByStep = Button("Passo a passo", IniciarAnimacaoPassoAPasso)
else:
self.btnStepByStep = Button("Passo a passo", self.onIniciarAnimacaoPassoAPasso)
self.btnFazer = Button("fazer >>", fazerProxOperacao)
# self.btnFazer.setEnabled(False);
self.btnDesfazer = Button("<< desfazer", desfazerProxOperacao)
# self.btnDesfazer.setEnabled(False);
self.btnFechar = PushButton(imageFechar, imageFechar)
self.btnTestarResposta = Button("Testar Solução")
self.lbVelocidade = ListBox()
self.lbVelocidade.setID("lbseg")
self.lbVelocidade.addItem("0.5 segundo", value=2)
self.lbVelocidade.addItem("1 segundo", value=1)
self.lbVelocidade.addItem("2 segundos", value=0.5)
self.lbVelocidade.addItem("3 segundos", value=1 / 3)
self.lbVelocidade.addItem("4 segundos", value=0.25)
self.lbVelocidade.addItem("5 segundos", value=0.20)
self.lbVelocidade.addItem("6 segundos", value=0.167)
self.lbVelocidade.addItem("7 segundos", value=0.143)
self.lbVelocidade.addItem("8 segundos", value=0.125)
self.lbVelocidade.addItem("10 segundos", value=0.1)
lblinha1 = ListBox()
lblinha1.setID("lm1")
lblinha1.addItem("1", value=1)
lblinha1.addItem("2", value=2)
lblinha1.addItem("3", value=3)
lblinha1.addItem("4", value=4)
lblinha1.addItem("5", value=5)
lblinha2 = ListBox()
lblinha2.setID("lm2")
lblinha2.addItem("1", value=1)
lblinha2.addItem("2", value=2)
lblinha2.addItem("3", value=3)
lblinha2.addItem("4", value=4)
lblinha2.addItem("5", value=5)
lbcoluna1 = ListBox()
lbcoluna1.setID("cm1")
lbcoluna1.addItem("1", value=1)
lbcoluna1.addItem("2", value=2)
lbcoluna1.addItem("3", value=3)
lbcoluna1.addItem("4", value=4)
lbcoluna1.addItem("5", value=5)
lbcoluna1.addItem("6", value=6)
lbcoluna1.addItem("7", value=7)
lbcoluna2 = ListBox()
lbcoluna2.setID("cm2")
lbcoluna2.addItem("1", value=1)
lbcoluna2.addItem("2", value=2)
lbcoluna2.addItem("3", value=3)
lbcoluna2.addItem("4", value=4)
lbcoluna2.addItem("5", value=5)
lbcoluna2.addItem("6", value=6)
lbcoluna2.addItem("7", value=7)
self.lblStatus = Label("Label para Status")
#.........这里部分代码省略.........