本文整理汇总了Python中pyjamas.ui.FlexTable.FlexTable.setWidget方法的典型用法代码示例。如果您正苦于以下问题:Python FlexTable.setWidget方法的具体用法?Python FlexTable.setWidget怎么用?Python FlexTable.setWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.FlexTable.FlexTable
的用法示例。
在下文中一共展示了FlexTable.setWidget方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setWidget [as 别名]
class RegexTextBoxDemo:
def onModuleLoad(self):
_example_descr=HTML("""This example shows how to validate text using
a TextBox. A new class called RegexTextBox, which inherits from TextBox
validates text, when focus is removed (ie, onblur event).<br>
In the table below, TextBoxes in the 'Valid Text' column contain text
strings that match that rows regular expression. TextBoxes in the 'Invalid Text'
column contain strings that violates the same regular expressions. Feel free
to modify the text to test different values to see if they are valid or not.
<p>""")
self._table=FlexTable(BorderWidth=0)
self._table.setStyleName("gwt-table")
self._setHeaders()
self._row=1
for _descr, _regex, _correct, _wrong in self._get_data():
self._rowHelper(_descr, _regex, _correct, _wrong)
self._row+=1
_panel=VerticalPanel()
_panel.add(_example_descr)
_panel.add(self._table)
RootPanel().add(_panel)
def _setHeaders(self):
self._table.setHTML(0,0, "<b>Description</b>")
self._table.setHTML(0,1, "<b>Regex</b>")
self._table.setHTML(0,2, "<b>Valid Text</b>")
self._table.setHTML(0,3, "<b>Invalid Text</b>")
def _rowHelper(self, text, regex, value1, value2):
self._table.setHTML(self._row, 0, text)
self._table.setHTML(self._row, 1, regex)
_rtb=RegexTextBox()
_rtb.setRegex(regex)
_rtb.setText(value1)
_rtb.appendValidListener(display_ok)
_rtb.appendInvalidListener(display_error)
_rtb.validate(None)
self._table.setWidget(self._row, 2, _rtb)
_rtb1=RegexTextBox()
_rtb1.setRegex(regex)
_rtb1.setText(value2)
_rtb1.appendValidListener(display_ok)
_rtb1.appendInvalidListener(display_error)
_rtb1.validate(None)
self._table.setWidget(self._row, 3, _rtb1)
def _get_data(self):
return [['Positive Unsigned Integer', r'^\d+$', '123', '1a2'],
['Signed Integer', r'^[+-]?\d+$', '+321', '321-'],
['No whitespace', r'^\S+$', 'pyjamas', '1 3'],
['Date in (MM/DD/YYYY) format', r'^\d\d/\d\d/\d{4}$',
'12/21/2012', '12-21-2012'],
['Non digits', r'^\D+$', 'pyjamas', '1 3'],
]
示例2: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setWidget [as 别名]
def __init__(self):
VerticalPanel.__init__(self, Width="500px", Height="300px")
table = FlexTable()
for i, sentence in enumerate(["The dog is red", "The cat is blue", "The bear is green"]):
table.setWidget(i, 0, CodeSwitchingSentence(sentence))
self.add(table)
示例3: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setWidget [as 别名]
def __init__(self, tokens):
"""
Note that here tokens must be a list of lists
"""
VerticalPanel.__init__(self)
table = FlexTable()
self.bio_widgets = []
for i, token_list in enumerate(tokens):
self.bio_widgets.append(BIOhighlighter(i, token_list))
table.setWidget(i, 0, self.bio_widgets[i])
self.add(table)
示例4: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setWidget [as 别名]
def __init__(self):
VerticalPanel.__init__(self)
table = FlexTable()
sentences = self.get_stimuli()
sentence_widgets = []
self.sentence_set = BIO.BIOSentenceSet(sentences,[x.split() for x in sentences])
table.setWidget(0,0,self.sentence_set)
self.add(table)
示例5: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setWidget [as 别名]
def __init__(self,sentences,tokens):
"""
Note that here tokens must be a list of lists
"""
VerticalPanel.__init__(self)
options = ["Not Selected","Person","Location","Organization","Date","Time","Money","Percent","Url","Email","Telephone Number","English (Code Switching)"]
table = FlexTable()
self.bio_widgets = []
for i,pair in enumerate(zip(sentences,tokens)):
self.bio_widgets.append(BIOHighlighterDropDown(i,pair[0],pair[1],options))
table.setWidget(i,0,self.bio_widgets[i])
self.add(table)
示例6: FlexTableDemo
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setWidget [as 别名]
class FlexTableDemo(SimplePanel):
def __init__(self):
SimplePanel.__init__(self)
self._table = FlexTable(BorderWidth=1, Width="100%")
cellFormatter = self._table.getFlexCellFormatter()
rowFormatter = self._table.getRowFormatter()
self._table.setHTML(0, 0, "<b>Mammals</b>")
self._table.setText(1, 0, "Cow")
self._table.setText(1, 1, "Rat")
self._table.setText(1, 2, "Dog")
cellFormatter.setColSpan(0, 0, 3)
cellFormatter.setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER)
self._table.setWidget(2, 0, Button("Hide", getattr(self, "hideRows")))
self._table.setText(2, 1, "1,1")
self._table.setText(2, 2, "2,1")
self._table.setText(3, 0, "1,2")
self._table.setText(3, 1, "2,2")
cellFormatter.setRowSpan(2, 0, 2)
cellFormatter.setVerticalAlignment(2, 0, HasAlignment.ALIGN_MIDDLE)
self._table.setWidget(4, 0, Button("Show", getattr(self, "showRows")))
cellFormatter.setColSpan(4, 0, 3)
rowFormatter.setVisible(4, False)
self.add(self._table)
def hideRows(self, sender):
rowFormatter = self._table.getRowFormatter()
rowFormatter.setVisible(2, False)
rowFormatter.setVisible(3, False)
rowFormatter.setVisible(4, True)
def showRows(self, sender):
rowFormatter = self._table.getRowFormatter()
rowFormatter.setVisible(2, True)
rowFormatter.setVisible(3, True)
rowFormatter.setVisible(4, False)