本文整理汇总了Python中gramps.gui.plug.quick.QuickTable.row_sort_val方法的典型用法代码示例。如果您正苦于以下问题:Python QuickTable.row_sort_val方法的具体用法?Python QuickTable.row_sort_val怎么用?Python QuickTable.row_sort_val使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gui.plug.quick.QuickTable
的用法示例。
在下文中一共展示了QuickTable.row_sort_val方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from gramps.gui.plug.quick import QuickTable [as 别名]
# 或者: from gramps.gui.plug.quick.QuickTable import row_sort_val [as 别名]
def run(database, document, date):
"""
Display people probably alive and their ages on a particular date.
"""
# setup the simple access functions
sdb = SimpleAccess(database)
sdoc = SimpleDoc(document)
stab = QuickTable(sdb)
if not date.get_valid():
sdoc.paragraph("Date is not a valid date.")
return
# display the title
if date.get_day_valid():
sdoc.title(_("People and their ages the %s") %
displayer.display(date))
else:
sdoc.title(_("People and their ages on %s") %
displayer.display(date))
stab.columns(_("Person"), _("Age"), _("Status")) # Actual Date makes column unicode
alive_matches = 0
dead_matches = 0
for person in sdb.all_people():
alive, birth, death, explain, relative = \
probably_alive(person, database, date, return_range=True)
# Doesn't show people probably alive but no way of figuring an age:
if alive:
if birth:
diff_span = (date - birth)
stab.row(person, str(diff_span), _("Alive: %s") % explain)
stab.row_sort_val(1, int(diff_span))
else:
stab.row(person, "", _("Alive: %s") % explain)
stab.row_sort_val(1, 0)
alive_matches += 1
else: # not alive
if birth:
diff_span = (date - birth)
stab.row(person, str(diff_span), _("Deceased: %s") % explain)
stab.row_sort_val(1, int(diff_span))
else:
stab.row(person, "", _("Deceased: %s") % explain)
stab.row_sort_val(1, 1)
dead_matches += 1
document.has_data = (alive_matches + dead_matches) > 0
sdoc.paragraph(_("\nLiving matches: %(alive)d, "
"Deceased matches: %(dead)d\n") %
{'alive' : alive_matches, 'dead' : dead_matches})
if document.has_data:
stab.write(sdoc)
sdoc.paragraph("")
示例2: run
# 需要导入模块: from gramps.gui.plug.quick import QuickTable [as 别名]
# 或者: from gramps.gui.plug.quick.QuickTable import row_sort_val [as 别名]
def run(database, document, person):
"""
Display a person's timeline.
"""
sa = SimpleAccess(database)
sd = SimpleDoc(document)
sd.title(_("Timeline for %s") % sa.name(person))
sd.paragraph("")
stab = QuickTable(sa)
stab.columns(_("Date"),
_("Event"),
_("Age"),
_("Place"),
_("People involved"))
stab.set_link_col(4)
handled = {}
birth_ref = gramps.gen.lib.Person.get_birth_ref(person)
birth_date = get_event_date_from_ref(database, birth_ref)
event_list = []
process(database, sa, event_list, handled, person, False, person)
for (event, obj, desc) in sorted(event_list, key=by_date):
edate = sa.event_date_obj(event)
span_str, span_int = format_date(birth_date, edate, obj == person)
if desc == None:
desc = event
stab.row(edate,
desc,
span_str,
sa.event_place(event),
obj)
stab.row_sort_val(2, span_int)
today = Today()
span_str, span_int = format_date(birth_date, today, False)
stab.row(today, _("Today"), span_str, "", person)
stab.row_sort_val(2, span_int)
stab.write(sd)
sd.paragraph("")
示例3: run
# 需要导入模块: from gramps.gui.plug.quick import QuickTable [as 别名]
# 或者: from gramps.gui.plug.quick.QuickTable import row_sort_val [as 别名]
def run(database, document, person):
sdoc = SimpleDoc(document)
name = gramps.gen.display.name.displayer.display(person)
death_date = _get_date(database, person.get_death_ref())
sdoc.title(_("Number of %s's descendants") % name)
sdoc.paragraph("")
total = []
seen = []
outlived = []
alive = []
handles = []
_count_descendants(database, person, death_date, 0,
total, seen, outlived, alive, handles)
# Bring all lists to the same length. No list can be longer than "total".
while len(seen) < len(total):
seen.append(0)
while len(outlived) < len(total):
outlived.append(0)
while len(alive) < len(total):
alive.append(0)
rel_calc = get_relationship_calculator()
stab = QuickTable(document)
if death_date:
stab.columns(
_("Generation"),
_("Total"),
_("Seen"),
_("Outlived"),
_("Now alive"))
else:
stab.columns(
_("Generation"),
_("Total"),
_("Now alive"))
n = 0
for (a, b, c, d, h) in zip(total, seen, outlived, alive, handles):
n += 1
generation = rel_calc.get_plural_relationship_string(0, n)
if death_date:
# stab.row([generation, "PersonList"] + h, a, b, c, d) # Needs 3.2
stab.row(generation, a, b, c, d)
else:
# stab.row([generation, "PersonList"] + h, a, d) # Needs 3.2
stab.row(generation, a, d)
stab.row_sort_val(0, n)
if death_date:
# stab.row([_("Total"), "PersonList"] + sum(handles, []), # Needs 3.2
stab.row(_("Total"),
sum(total), sum(seen), sum(outlived), sum(alive))
else:
# stab.row([_("Total"), "PersonList"] + sum(handles, []), # Needs 3.2
stab.row(_("Total"),
sum(total), sum(alive))
stab.row_sort_val(0, n + 1)
stab.write(sdoc)
if death_date:
sdoc.paragraph(_("Seen = number of descendants whose birth %s has "
"lived to see") % name)
sdoc.paragraph(_("Outlived = number of descendants who died while %s "
"was still alive") % name)