本文整理汇总了Python中etgen.html.E.h5方法的典型用法代码示例。如果您正苦于以下问题:Python E.h5方法的具体用法?Python E.h5怎么用?Python E.h5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类etgen.html.E
的用法示例。
在下文中一共展示了E.h5方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: table2html
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import h5 [as 别名]
def table2html(ar, as_main=True):
"""Represent the given table request as an HTML table.
`ar` is the request to be rendered, an instance of
:class:`lino.core.tablerequest.TableRequest`.
The returned HTML enclosed in a ``<div>`` tag and generated using
:mod:`etgen.html`.
If `as_main` is True, include additional elements such as a paging
toolbar. (This argument is currently being ignored.)
"""
# as_main = True
t = xghtml.Table()
t.attrib.update(**{'class':"table table-striped table-hover"})
if ar.limit is None:
ar.limit = PLAIN_PAGE_LENGTH
pglen = ar.limit
if ar.offset is None:
page = 1
else:
"""
(assuming pglen is 5)
offset page
0 1
5 2
"""
page = int(old_div(ar.offset, pglen)) + 1
ar.dump2html(t, ar.sliced_data_iterator, header_links=as_main)
if not as_main:
url = ar.get_request_url() # open in own window
return E.div(
E.div(
E.div(
E.a(
E.span(**{'class':"glyphicon glyphicon-folder-open"}),
href=url, style="margin-left: 4px;",
**{'class':"btn btn-default pull-right"}),
E.h5(ar.get_title(), style="display: inline-block;"),
**{'class': "panel-title"}),
**{'class':"panel-heading"}),
t.as_element(),
style="display: inline-block;",
**{'class':"panel panel-default"})
buttons = []
kw = dict()
kw = {}
if pglen != PLAIN_PAGE_LENGTH:
kw[constants.URL_PARAM_LIMIT] = pglen
if page > 1:
kw[constants.URL_PARAM_START] = pglen * (page - 2)
prev_url = ar.get_request_url(**kw)
kw[constants.URL_PARAM_START] = 0
first_url = ar.get_request_url(**kw)
else:
prev_url = None
first_url = None
buttons.append(('<<', _("First page"), first_url))
buttons.append(('<', _("Previous page"), prev_url))
next_start = pglen * page
if next_start < ar.get_total_count():
kw[constants.URL_PARAM_START] = next_start
next_url = ar.get_request_url(**kw)
last_page = int(old_div((ar.get_total_count() - 1), pglen))
kw[constants.URL_PARAM_START] = pglen * last_page
last_url = ar.get_request_url(**kw)
else:
next_url = None
last_url = None
buttons.append(('>', _("Next page"), next_url))
buttons.append(('>>', _("Last page"), last_url))
return E.div(buttons2pager(buttons), t.as_element())