本文整理汇总了Python中gluon.html.TR属性的典型用法代码示例。如果您正苦于以下问题:Python html.TR属性的具体用法?Python html.TR怎么用?Python html.TR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gluon.html
的用法示例。
在下文中一共展示了html.TR属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: formstyle_table3cols
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [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 TR [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_HTML
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [as 别名]
def test_HTML(self):
self.assertEqual(HTML('<>', _a='1', _b='2').xml(),
b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html a="1" b="2" lang="en"><></html>')
self.assertEqual(HTML('<>', _a='1', _b='2', doctype='strict').xml(),
b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html a="1" b="2" lang="en"><></html>')
self.assertEqual(HTML('<>', _a='1', _b='2', doctype='transitional').xml(),
b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html a="1" b="2" lang="en"><></html>')
self.assertEqual(HTML('<>', _a='1', _b='2', doctype='frameset').xml(),
b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">\n<html a="1" b="2" lang="en"><></html>')
self.assertEqual(HTML('<>', _a='1', _b='2', doctype='html5').xml(),
b'<!DOCTYPE HTML>\n<html a="1" b="2" lang="en"><></html>')
self.assertEqual(HTML('<>', _a='1', _b='2', doctype='').xml(),
b'<html a="1" b="2" lang="en"><></html>')
self.assertEqual(HTML('<>', _a='1', _b='2', doctype='CustomDocType').xml(),
b'CustomDocType\n<html a="1" b="2" lang="en"><></html>')
示例4: test_TR
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [as 别名]
def test_TR(self):
self.assertEqual(TR('<>', _a='1', _b='2').xml(),
b'<tr a="1" b="2"><td><></td></tr>')
示例5: test_THEAD
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [as 别名]
def test_THEAD(self):
self.assertEqual(THEAD('<>', _a='1', _b='2').xml(),
b'<thead a="1" b="2"><tr><th><></th></tr></thead>')
# self.assertEqual(THEAD(TRHEAD('<>'), _a='1', _b='2').xml(),
# '<thead a="1" b="2"><tr><th><></th></tr></thead>')
self.assertEqual(THEAD(TR('<>'), _a='1', _b='2').xml(),
b'<thead a="1" b="2"><tr><td><></td></tr></thead>')
示例6: sql_log_format
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [as 别名]
def sql_log_format(sql_log):
return CAT(
TABLE(
TR(B("TOTAL TIME: "), B('%.2fms' % sum([row[1] * 1000 for row in sql_log]))),
*[TR( nr+1, tidy_SQL(row[0]),
'%.2fms' % (row[1]*1000)
)
for nr, row in enumerate(sql_log)
]
)
, sql_log_style
)
示例7: table_template
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [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()
示例8: widget
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [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)
示例9: toolbar
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [as 别名]
def toolbar(self):
from gluon.html import DIV, SCRIPT, BEAUTIFY, TAG, A
BUTTON = TAG.button
admin = URL("admin", "default", "design", extension='html',
args=current.request.application)
from gluon.dal import DAL
dbstats = []
dbtables = {}
infos = DAL.get_instances()
for k, v in iteritems(infos):
dbstats.append(TABLE(*[TR(PRE(row[0]), '%.2fms' % (row[1]*1000))
for row in v['dbstats']]))
dbtables[k] = dict(defined=v['dbtables']['defined'] or '[no defined tables]',
lazy=v['dbtables']['lazy'] or '[no lazy tables]')
u = web2py_uuid()
backtotop = A('Back to top', _href="#totop-%s" % u)
# Convert lazy request.vars from property to Storage so they
# will be displayed in the toolbar.
request = copy.copy(current.request)
request.update(vars=current.request.vars,
get_vars=current.request.get_vars,
post_vars=current.request.post_vars)
return DIV(
BUTTON('design', _onclick="document.location='%s'" % admin),
BUTTON('request',
_onclick="jQuery('#request-%s').slideToggle()" % u),
BUTTON('response',
_onclick="jQuery('#response-%s').slideToggle()" % u),
BUTTON('session',
_onclick="jQuery('#session-%s').slideToggle()" % u),
BUTTON('db tables',
_onclick="jQuery('#db-tables-%s').slideToggle()" % u),
BUTTON('db stats',
_onclick="jQuery('#db-stats-%s').slideToggle()" % u),
DIV(BEAUTIFY(request), backtotop,
_class="w2p-toolbar-hidden", _id="request-%s" % u),
DIV(BEAUTIFY(current.session), backtotop,
_class="w2p-toolbar-hidden", _id="session-%s" % u),
DIV(BEAUTIFY(current.response), backtotop,
_class="w2p-toolbar-hidden", _id="response-%s" % u),
DIV(BEAUTIFY(dbtables), backtotop,
_class="w2p-toolbar-hidden", _id="db-tables-%s" % u),
DIV(BEAUTIFY(dbstats), backtotop,
_class="w2p-toolbar-hidden", _id="db-stats-%s" % u),
SCRIPT("jQuery('.w2p-toolbar-hidden').hide()"),
_id="totop-%s" % u
)
示例10: widget
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [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)
示例11: toolbar
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TR [as 别名]
def toolbar(self):
from gluon.html import DIV, SCRIPT, BEAUTIFY, TAG, A
BUTTON = TAG.button
admin = URL("admin", "default", "design", extension='html',
args=current.request.application)
from gluon.dal import DAL
dbstats = []
dbtables = {}
infos = DAL.get_instances()
for k, v in infos.iteritems():
dbstats.append(TABLE(*[TR(PRE(row[0]), '%.2fms' % (row[1]*1000))
for row in v['dbstats']]))
dbtables[k] = dict(defined=v['dbtables']['defined'] or '[no defined tables]',
lazy=v['dbtables']['lazy'] or '[no lazy tables]')
u = web2py_uuid()
backtotop = A('Back to top', _href="#totop-%s" % u)
# Convert lazy request.vars from property to Storage so they
# will be displayed in the toolbar.
request = copy.copy(current.request)
request.update(vars=current.request.vars,
get_vars=current.request.get_vars,
post_vars=current.request.post_vars)
return DIV(
BUTTON('design', _onclick="document.location='%s'" % admin),
BUTTON('request',
_onclick="jQuery('#request-%s').slideToggle()" % u),
BUTTON('response',
_onclick="jQuery('#response-%s').slideToggle()" % u),
BUTTON('session',
_onclick="jQuery('#session-%s').slideToggle()" % u),
BUTTON('db tables',
_onclick="jQuery('#db-tables-%s').slideToggle()" % u),
BUTTON('db stats',
_onclick="jQuery('#db-stats-%s').slideToggle()" % u),
DIV(BEAUTIFY(request), backtotop,
_class="w2p-toolbar-hidden", _id="request-%s" % u),
DIV(BEAUTIFY(current.session), backtotop,
_class="w2p-toolbar-hidden", _id="session-%s" % u),
DIV(BEAUTIFY(current.response), backtotop,
_class="w2p-toolbar-hidden", _id="response-%s" % u),
DIV(BEAUTIFY(dbtables), backtotop,
_class="w2p-toolbar-hidden", _id="db-tables-%s" % u),
DIV(BEAUTIFY(dbstats), backtotop,
_class="w2p-toolbar-hidden", _id="db-stats-%s" % u),
SCRIPT("jQuery('.w2p-toolbar-hidden').hide()"),
_id="totop-%s" % u
)