本文整理汇总了Python中etgen.html.E.table方法的典型用法代码示例。如果您正苦于以下问题:Python E.table方法的具体用法?Python E.table怎么用?Python E.table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类etgen.html.E
的用法示例。
在下文中一共展示了E.table方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: weeklyNavigation
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import table [as 别名]
def weeklyNavigation(cls, obj, ar):
today = obj.date
prev = cls.date2pk(DurationUnits.months.add_duration(today, -1))
next = cls.date2pk(DurationUnits.months.add_duration(today, 1))
elems = cls.calender_header(ar)
header = [
ar.goto_pk(prev, "<<"), " ",
"{} {}".format(monthname(today.month), today.year),
" ", ar.goto_pk(next, ">>")]
elems.append(E.h2(*header, align="center"))
rows = []
for week in CALENDAR.monthdatescalendar(today.year, today.month):
# each week is a list of seven datetime.date objects.
cells = []
current_week = week[0].isocalendar()[1]
cells.append(E.td(str(current_week)))
for day in week:
pk = cls.date2pk(day)
if day.isocalendar()[1] == today.isocalendar()[1]:
cells.append(E.td(str(day.day)))
else:
cells.append(E.td(ar.goto_pk(pk, str(day.day))))
rows.append(E.tr(*cells, align="center"))
elems.append(E.table(*rows, align="center"))
elems.append(E.p(ar.goto_pk(0, gettext("This week")), align="center"))
# for o in range(-10, 10):
# elems.append(ar.goto_pk(o, str(o)))
# elems.append(" ")
return E.div(*elems)
示例2: to_html
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import table [as 别名]
def to_html(self, ar):
self.analyze_view()
get_rnd = rt.models.cal.EventGenerator.get_cal_entry_renderer
if self.mode == TABLE_MODE:
sep = ' '
fmt = get_rnd(day_and_weekday)
elif self.mode == UL_MODE:
sep = ' '
fmt = get_rnd(day_and_weekday)
elif self.mode == PLAIN_MODE:
sep = ', '
fmt = get_rnd(dd.fds)
def xxx(list_of_entries):
elems = []
for e in list_of_entries:
if len(elems):
elems.append(sep)
elems.extend(fmt(e, ar))
return elems
if self.mode == TABLE_MODE:
rows = []
cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
# print(''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
for y in self.years.values():
cells = [E.td(str(y.year), width="4%")]
for m in y.months:
# every m is a list of etree elems
cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
# print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
return E.table(*rows, **ar.renderer.tableattrs)
if self.mode == UL_MODE:
items = []
for y in self.years.values():
for m, lst in enumerate(y.months):
if len(lst):
items.append(E.li(
monthname(m+1), " ", str(y.year), ": ", *xxx(lst)))
return E.ul(*items)
if self.mode == PLAIN_MODE:
elems = []
for y in self.years.values():
for lst in y.months:
if len(lst):
if len(elems):
elems.append(sep)
elems.extend(xxx(lst))
return E.p(*elems)
raise Exception("20180720")
示例3: to_html
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import table [as 别名]
def to_html(self, ar):
self.analyze_view()
if self.mode == TABLE_MODE:
sep = ' '
fmt = day_and_weekday
elif self.mode == UL_MODE:
sep = ' '
fmt = day_and_weekday
elif self.mode == PLAIN_MODE:
sep = ', '
fmt = dd.fds
def rnd(obj, ar):
if self.model is rt.models.cal.Guest:
d = obj.event.start_date
evt = obj.event
else:
d = obj.start_date
evt = obj
# if show_auto_num and evt.auto_type:
# yield str(evt.auto_type)+":"
yield ar.obj2html(evt, fmt(d))
if obj.state.button_text:
yield str(obj.state.button_text)
# return (fdmy(d) + ": ", ar.obj2html(evt, lbl))
def xxx(list_of_entries):
elems = []
# for e in reversed(list_of_entries):
for e in list_of_entries:
if len(elems):
elems.append(sep)
elems.extend(rnd(e, ar))
return elems
if self.mode == TABLE_MODE:
rows = []
cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
# print(''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
for y in self.years.values():
cells = [E.td(str(y.year), width="4%")]
for m in y.months:
# every m is a list of etree elems
cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
# print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
return E.table(*rows, **ar.renderer.tableattrs)
if self.mode == UL_MODE:
items = []
for y in self.years.values():
for m, lst in enumerate(reversed(y.months)):
# January is [11], Dec is [0]
if len(lst):
items.append(E.li(
monthname(12-m), " ", str(y.year), ": ", *xxx(lst)))
return E.ul(*items)
if self.mode == PLAIN_MODE:
elems = []
for y in self.years.values():
for lst in y.months:
if len(lst):
if len(elems):
elems.append(sep)
elems.extend(xxx(lst))
return E.p(*elems)
raise Exception("20180720")