本文整理汇总了Python中pyjamas.ui.TextBox.TextBox.setName方法的典型用法代码示例。如果您正苦于以下问题:Python TextBox.setName方法的具体用法?Python TextBox.setName怎么用?Python TextBox.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.TextBox.TextBox
的用法示例。
在下文中一共展示了TextBox.setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onModuleLoad
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setName [as 别名]
class FormPanelExample:
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)
def onClick(self, sender):
self.form.submit()
def onSubmitComplete(self, event):
# When the form submission is successfully completed, this event is
# fired. Assuming the service returned a response of type text/plain,
# we can get the result text here (see the FormPanel documentation for
# further explanation).
Window.alert(event.getResults())
def onSubmit(self, event):
# This event is fired just before the form is submitted. We can take
# this opportunity to perform validation.
if self.tb.getText().length == 0:
Window.alert("The text box must not be empty")
event.setCancelled(True)
示例2: addRow
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setName [as 别名]
def addRow(self, timeVO = None):
self.rows += 1
col = -1
for name, maxLength, visibleLength in self.columns:
col += 1
textBox = TextBox()
textBox.setText("")
textBox.col = col
textBox.row = self.rows
textBox.addChangeListener(self.checkValid)
textBox.addKeyboardListener(self)
textBox.addFocusListener(self)
textBox.setName(name)
if not maxLength is None:
textBox.setMaxLength(maxLength)
if not visibleLength is None:
textBox.setVisibleLength(visibleLength)
self.setWidget(self.rows, col, textBox)
if not timeVO is None:
self.setRow(self.rows, timeVO)