本文整理汇总了Python中gluon.html.TD属性的典型用法代码示例。如果您正苦于以下问题:Python html.TD属性的具体用法?Python html.TD怎么用?Python html.TD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gluon.html
的用法示例。
在下文中一共展示了html.TD属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: formstyle_table3cols
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TD [as 别名]
def formstyle_table3cols(form, fields):
""" 3 column table - default """
table = TABLE()
for id, label, controls, help in fields:
_help = TD(help, _class='w2p_fc')
_controls = TD(controls, _class='w2p_fw')
_label = TD(label, _class='w2p_fl')
table.append(TR(_label, _controls, _help, _id=id))
return table
示例2: formstyle_table2cols
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TD [as 别名]
def formstyle_table2cols(form, fields):
""" 2 column table """
table = TABLE()
for id, label, controls, help in fields:
_help = TD(help, _class='w2p_fc', _width='50%')
_controls = TD(controls, _class='w2p_fw', _colspan='2')
_label = TD(label, _class='w2p_fl', _width='50%')
table.append(TR(_label, _help, _id=id + '1', _class='w2p_even even'))
table.append(TR(_controls, _id=id + '2', _class='w2p_even odd'))
return table
示例3: test_TD
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TD [as 别名]
def test_TD(self):
self.assertEqual(TD('<>', _a='1', _b='2').xml(),
b'<td a="1" b="2"><></td>')
示例4: table_template
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TD [as 别名]
def table_template(table):
from gluon.html import TR, TD, TABLE, TAG
def FONT(*args, **kwargs):
return TAG.font(*args, **kwargs)
def types(field):
f_type = field.type
if not isinstance(f_type,str):
return ' '
elif f_type == 'string':
return field.length
elif f_type == 'id':
return B('pk')
elif f_type.startswith('reference') or \
f_type.startswith('list:reference'):
return B('fk')
else:
return ' '
# This is horribe HTML but the only one graphiz understands
rows = []
cellpadding = 4
color = "#000000"
bgcolor = "#FFFFFF"
face = "Helvetica"
face_bold = "Helvetica Bold"
border = 0
rows.append(TR(TD(FONT(table, _face=face_bold, _color=bgcolor),
_colspan=3, _cellpadding=cellpadding,
_align="center", _bgcolor=color)))
for row in db[table]:
rows.append(TR(TD(FONT(row.name, _color=color, _face=face_bold),
_align="left", _cellpadding=cellpadding,
_border=border),
TD(FONT(row.type, _color=color, _face=face),
_align="left", _cellpadding=cellpadding,
_border=border),
TD(FONT(types(row), _color=color, _face=face),
_align="center", _cellpadding=cellpadding,
_border=border)))
return "< %s >" % TABLE(*rows, **dict(_bgcolor=bgcolor, _border=1,
_cellborder=0, _cellspacing=0)
).xml()
示例5: widget
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TD [as 别名]
def widget(cls, field, value, **attributes):
"""
Generates a TABLE tag, including INPUT radios (only 1 option allowed)
see also: `FormWidget.widget`
"""
if isinstance(value, (list, tuple)):
value = str(value[0])
else:
value = str(value)
attr = cls._attributes(field, {}, **attributes)
attr['_class'] = add_class(attr.get('_class'), 'web2py_radiowidget')
requires = field.requires
if not isinstance(requires, (list, tuple)):
requires = [requires]
if requires:
if hasattr(requires[0], 'options'):
options = requires[0].options()
else:
raise SyntaxError('widget cannot determine options of %s'
% field)
options = [(k, v) for k, v in options if str(v)]
opts = []
cols = attributes.get('cols', 1)
totals = len(options)
mods = totals % cols
rows = totals // cols
if mods:
rows += 1
# widget style
wrappers = dict(
table=(TABLE, TR, TD),
ul=(DIV, UL, LI),
divs=(DIV, DIV, DIV)
)
parent, child, inner = wrappers[attributes.get('style', 'table')]
for r_index in range(rows):
tds = []
for k, v in options[r_index * cols:(r_index + 1) * cols]:
checked = {'_checked': 'checked'} if k == value else {}
tds.append(inner(INPUT(_type='radio',
_id='%s%s' % (field.name, k),
_name=field.name,
requires=attr.get('requires', None),
hideerror=True, _value=k,
value=value,
**checked),
LABEL(v, _for='%s%s' % (field.name, k))))
opts.append(child(tds))
if opts:
opts[-1][0][0]['hideerror'] = False
return parent(*opts, **attr)
示例6: widget
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TD [as 别名]
def widget(cls, field, value, **attributes):
"""
Generates a TABLE tag, including INPUT radios (only 1 option allowed)
see also: `FormWidget.widget`
"""
if isinstance(value, (list, tuple)):
value = str(value[0])
else:
value = str(value)
attr = cls._attributes(field, {}, **attributes)
attr['_class'] = add_class(attr.get('_class'), 'web2py_radiowidget')
requires = field.requires
if not isinstance(requires, (list, tuple)):
requires = [requires]
if requires:
if hasattr(requires[0], 'options'):
options = requires[0].options()
else:
raise SyntaxError('widget cannot determine options of %s'
% field)
options = [(k, v) for k, v in options if str(v)]
opts = []
cols = attributes.get('cols', 1)
totals = len(options)
mods = totals % cols
rows = totals / cols
if mods:
rows += 1
# widget style
wrappers = dict(
table=(TABLE, TR, TD),
ul=(DIV, UL, LI),
divs=(DIV, DIV, DIV)
)
parent, child, inner = wrappers[attributes.get('style', 'table')]
for r_index in range(rows):
tds = []
for k, v in options[r_index * cols:(r_index + 1) * cols]:
checked = {'_checked': 'checked'} if k == value else {}
tds.append(inner(INPUT(_type='radio',
_id='%s%s' % (field.name, k),
_name=field.name,
requires=attr.get('requires', None),
hideerror=True, _value=k,
value=value,
**checked),
LABEL(v, _for='%s%s' % (field.name, k))))
opts.append(child(tds))
if opts:
opts[-1][0][0]['hideerror'] = False
return parent(*opts, **attr)