1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| import gen.lib
from gen.plug.menu import (BooleanOption, NumberOption, TextOption, FamilyOption, EnumeratedListOption)
from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
TableCellStyle, FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
import DateHandler
from gen.ggettext import sgettext as _
from gen.display.name import displayer as global_name_display
#------------------------------------------------------------------------
#
# FamilyGroup
#
#------------------------------------------------------------------------
class FamilyGroup(Report):
def __init__(self, database, options, user):
"""
Create the DetAncestorReport object that produces the report.
The arguments are:
database - the GRAMPS database instance
options - instance of the Options class for this report
user - a gen.user.User() instance
This report needs the following parameters (class variables)
that come in the options class.
family_handle - Handle of the family to write report on.
includeAttrs - Whether to include attributes
name_format - Preferred format to display names
"""
Report.__init__(self, database, options, user)
menu = options.menu
self.family_handle = None
family_id = menu.get_option_by_name('family_id').get_value()
family = database.get_family_from_gramps_id(family_id)
if family:
self.family_handle = family.get_handle()
else:
self.family_handle = None
# Copy the global NameDisplay so that we don't change application
# defaults.
self._name_display = copy.deepcopy(global_name_display)
name_format = menu.get_option_by_name("name_format").get_value()
if name_format != 0:
self._name_display.set_default_format(name_format)
get_option_by_name = menu.get_option_by_name
get_value = lambda name:get_option_by_name(name).get_value()
...
self.ok_photo = get_value('add_photo')
self.ok_missing = get_value('add_missing')
self.ok_test = get_value('add_test')
self.ok_path = get_value('add_path')
self.ok_column31 = int(get_value('add_column31'))
self.ok_column32 = int(get_value('add_column32'))
self.ok_column41 = get_value('add_column41')
self.ok_column42 = get_value('add_column42')
self.ok_column43 = get_value('add_column43')
#------------------------------------------------------------------------
#
# MenuReportOptions
#
#------------------------------------------------------------------------
class FamilyGroupOptions(MenuReportOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self, name, dbase):
MenuReportOptions.__init__(self, name, dbase)
def add_menu_options(self, menu):
...
##########################
add_option = partial(menu.add_option, _("Photos"))
##########################
add_photo = BooleanOption(_("Add photos to parents and childs "),False)
add_photo.set_help(_("Add photos to parents and childs "))
add_option("add_photo", add_photo)
add_missing = BooleanOption(_("Add default photos when missing "),True)
add_missing.set_help(_("Add default photos when missing "))
add_option("add_missing", add_missing)
add_test = BooleanOption(_("Add personID for test "),False)
add_test.set_help(_("Add personID to test if photo names are ok"))
add_option("add_test", add_test)
add_path = TextOption(_("Photos path "),"")
add_path.set_help(_("The path where to find book photos. If empty, uses MediaPath "))
add_option("add_path", add_path)
add_column31 = NumberOption(_('Parent 2st tab Width (date)'), 40, 15, 40)
add_column31.set_help(_("Set the width of the second column (line date tab) in parent table. "))
menu.add_option("Photos", 'add_column31', add_column31)
add_column32 = NumberOption(_('Parent 3rd tab Width (place)'), 40, 40, 65)
add_column32.set_help(_("Set the width of the third column (line place tab) in parent table. "))
menu.add_option("Photos", 'add_column32', add_column32)
add_column41 = NumberOption(_('Child 2st tab Width (title)'), 18, 10, 18)
add_column41.set_help(_("Set the width of the second column (line title tab) in child table. "))
menu.add_option("Photos", 'add_column41', add_column41)
add_column42 = NumberOption(_('Child 3rd tab Width (date)'), 35, 15, 40)
add_column42.set_help(_("Set the width of the third column (line date tab) in child table. "))
menu.add_option("Photos", 'add_column42', add_column42)
add_column43 = NumberOption(_('Child 4th tab Width (place)'), 40, 40, 65)
add_column43.set_help(_("Set the width of the fourth column (line place tab) in child table. "))
menu.add_option("Photos", 'add_column43', add_column43)
...
def make_default_style(self,default_style):
"""Make default output style for the Family Group Report."""
...
table = TableStyle()
table.set_width(100)
table.set_columns(3)
table.set_column_width(0,20)
# table.set_column_width(1,27)
table.set_column_width(1,self.ok_column31)
# table.set_column_width(2,53)
table.set_column_width(2,self.ok_column32)
default_style.add_table_style('FGR-ParentTable',table)
table = TableStyle()
table.set_width(100)
table.set_columns(4)
table.set_column_width(0,7)
table.set_column_width(1,13)
# table.set_column_width(1,self.ok_column41)
table.set_column_width(2,27)
# table.set_column_width(1,self.ok_column42)
table.set_column_width(3,53)
# table.set_column_width(1,self.ok_column43)
default_style.add_table_style('FGR-ChildTable',table) |
Partager