diff --git a/MyTimeline.py b/MyTimeline.py index c074673..1fe5ed2 100644 --- a/MyTimeline.py +++ b/MyTimeline.py @@ -608,7 +608,7 @@ class MyTimelineView(NavigationView): clicked_index = self.find_event_at_position(event.x, event.y) if clicked_index is not None: # Check if clicking on marker (for person selection) or label (for expansion) - date_sort, date_obj, clicked_event, clicked_person, event_type, expanded, _ = self.events[clicked_index] + date_sort, date_obj, clicked_event, clicked_person, event_type, expanded, _y_pos = self.events[clicked_index] # Check if click is on marker area (left side) or label area (right side) timeline_x = TIMELINE_MARGIN_LEFT @@ -877,7 +877,7 @@ class MyTimelineView(NavigationView): # Calculate initial Y positions based on dates events_with_y_pos = [] for i, event_data in enumerate(self.events): - date_sort, date_obj, event, person, event_type, expanded, _ = event_data + date_sort, date_obj, event, person, event_type, expanded, _y_pos = event_data # Calculate Y position based on date y_pos = TIMELINE_MARGIN_TOP + ( @@ -1226,7 +1226,7 @@ class MyTimelineView(NavigationView): context.set_line_width(1.5) # Create a smooth curve through all points - y_positions = [y for y, _ in person_events] + y_positions = [y for y, _event_data in person_events] min_y = min(y_positions) max_y = max(y_positions) diff --git a/demo_family.gramps b/demo_family.gramps index 12102d2..b03ddec 100644 --- a/demo_family.gramps +++ b/demo_family.gramps @@ -11,279 +11,1504 @@ - + Birth - + Birth of Smith, John - + Death - + Death of Smith, John - + Birth - + Birth of Smith, Mary - + Death - + Death of Smith, Mary - + Marriage - + Marriage - + Birth - - Birth of Smith, Timothy + + Birth of Smith, Brandon - + Birth - - Birth of Smith, Samantha + + Birth of Smith, Amy - - Birth - - Birth of Smith, Anthony - - + Death - - Death of Smith, Anthony + + Death of Smith, Amy - + Birth - - Birth of Smith, Christine + + Birth of Smith, Brandon - - Birth - - Birth of Smith, Nicholas - - - Birth - - Birth of Smith, Pamela - - - Birth - - Birth of Smith, Edward - - + Death - - Death of Smith, Edward + + Death of Smith, Brandon - + Birth - - Birth of Smith, Shirley - - - Birth - - Birth of Smith, John - - - Birth - - Birth of Smith, Melissa - - - Birth - - Birth of Smith, Stephen - - - Birth - - Birth of Smith, Jennifer - - - Birth - - Birth of Smith, Daniel - - - Birth - - Birth of Smith, Rebecca - - - Birth - - Birth of Smith, Justin - - - Marriage - - Marriage - - - Marriage - - Marriage - - - Marriage - - Marriage - - - Marriage - - Marriage - - - Marriage - - Marriage - - - Birth - - Birth of Smith, Sarah - - - Birth - - Birth of Smith, Nicholas - - - Birth - - Birth of Smith, Mary - - - Birth - - Birth of Smith, Kevin - - - Birth - - Birth of Smith, Stephanie - - - Birth - - Birth of Smith, Nicholas - - - Birth - - Birth of Smith, Matthew - - - Birth - - Birth of Smith, Joshua - - - Birth - - Birth of Smith, Kimberly - - - Birth - - Birth of Smith, Andrew - - - Birth - - Birth of Smith, Shirley - - - Birth - - Birth of Smith, Timothy - - - Birth - - Birth of Smith, Cynthia - - - Birth - - Birth of Smith, Eric - - - Birth - - Birth of Smith, Laura - - - Birth - - Birth of Smith, Larry - - - Birth - - Birth of Smith, Katherine - - - Birth - - Birth of Smith, Brian - - - Birth - - Birth of Smith, John - - - Birth - - Birth of Smith, Brenda - - - Birth - - Birth of Smith, Donald - - - Birth - - Birth of Smith, Sharon - - - Birth - - Birth of Smith, Gary - - - Birth - + Birth of Smith, Betty - + Birth - - Birth of Smith, Joseph + + Birth of Smith, Richard - + Birth - + + Birth of Smith, Ashley + + + Death + + Death of Smith, Ashley + + + Birth + + Birth of Smith, Michael + + + Birth + + Birth of Smith, Elizabeth + + + Birth + + Birth of Smith, Nicholas + + + Death + + Death of Smith, Nicholas + + + Birth + + Birth of Smith, Rebecca + + + Birth + + Birth of Smith, William + + + Birth + Birth of Smith, Sharon + + Death + + Death of Smith, Sharon + + + Birth + + Birth of Smith, Benjamin + + + Birth + + Birth of Smith, Elizabeth + + + Birth + + Birth of Smith, Larry + + + Marriage + + Marriage + + + Marriage + + Marriage + + + Marriage + + Marriage + + + Marriage + + Marriage + + + Marriage + + Marriage + + + Birth + + Birth of Smith, Patricia + + + Birth + + Birth of Smith, John + + + Birth + + Birth of Smith, Linda + + + Birth + + Birth of Smith, Anthony + + + Birth + + Birth of Smith, Shirley + + + Birth + + Birth of Smith, James + + + Birth + + Birth of Smith, Stephen + + + Birth + + Birth of Smith, Ryan + + + Birth + + Birth of Smith, Margaret + + + Birth + + Birth of Smith, Michael + + + Birth + + Birth of Smith, Emily + + + Birth + + Birth of Smith, Jessica + + + Birth + + Birth of Smith, Charles + + + Birth + + Birth of Smith, Mary + + + Birth + + Birth of Smith, Richard + + + Birth + + Birth of Smith, Joshua + + + Birth + + Birth of Smith, Paul + + + Birth + + Birth of Smith, Donna + + + Birth + + Birth of Smith, Eric + + + Birth + + Birth of Smith, Sandra + + + Birth + + Birth of Smith, Nicholas + + + Birth + + Birth of Smith, Sandra + + + Birth + + Birth of Smith, Robert + + + Birth + + Birth of Smith, Donna + + + Birth + + Birth of Smith, Richard + + + Birth + + Birth of Smith, Brenda + + + Birth + + Birth of Smith, Timothy + + + Baptism + + Baptism of Smith, John + + + Christening + + Christening of Smith, John + + + Education + + Education - John Smith + + + Graduation + + Graduation - John Smith + + + Occupation + + Doctor - John Smith + + + Retirement + + Retirement - John Smith + + + Burial + + Burial of Smith, John + + + Baptism + + Baptism of Smith, Mary + + + Education + + Education - Mary Smith + + + Graduation + + Graduation - Mary Smith + + + Occupation + + Nurse - Mary Smith + + + Military Service + + Military Service - Mary Smith + + + Residence + + Residence in London - Mary Smith + + + Burial + + Burial of Smith, Mary + + + Baptism + + Baptism of Smith, Brandon + + + Christening + + Christening of Smith, Brandon + + + Occupation + + Lawyer - Brandon Smith + + + Military Service + + Military Service - Brandon Smith + + + Residence + + Residence in Vienna - Brandon Smith + + + Emigration + + Emigration - Brandon Smith + + + Retirement + + Retirement - Brandon Smith + + + Christening + + Christening of Smith, Amy + + + Education + + Education - Amy Smith + + + Occupation + + Nurse - Amy Smith + + + Military Service + + Military Service - Amy Smith + + + Residence + + Residence in Paris - Amy Smith + + + Burial + + Burial of Smith, Amy + + + Cremation + + Cremation of Smith, Amy + + + Education + + Education - Brandon Smith + + + Graduation + + Graduation - Brandon Smith + + + Occupation + + Doctor - Brandon Smith + + + Emigration + + Emigration - Brandon Smith + + + Cremation + + Cremation of Smith, Brandon + + + Baptism + + Baptism of Smith, Betty + + + Christening + + Christening of Smith, Betty + + + Education + + Education - Betty Smith + + + Graduation + + Graduation - Betty Smith + + + Occupation + + Farmer - Betty Smith + + + Residence + + Residence in Vienna - Betty Smith + + + Immigration + + Immigration - Betty Smith + + + Baptism + + Baptism of Smith, Richard + + + Education + + Education - Richard Smith + + + Graduation + + Graduation - Richard Smith + + + Occupation + + Carpenter - Richard Smith + + + Military Service + + Military Service - Richard Smith + + + Baptism + + Baptism of Smith, Ashley + + + Christening + + Christening of Smith, Ashley + + + Education + + Education - Ashley Smith + + + Emigration + + Emigration - Ashley Smith + + + Cremation + + Cremation of Smith, Ashley + + + Baptism + + Baptism of Smith, Michael + + + Christening + + Christening of Smith, Michael + + + Graduation + + Graduation - Michael Smith + + + Occupation + + Merchant - Michael Smith + + + Residence + + Residence in Amsterdam - Michael Smith + + + Emigration + + Emigration - Michael Smith + + + Baptism + + Baptism of Smith, Elizabeth + + + Education + + Education - Elizabeth Smith + + + Graduation + + Graduation - Elizabeth Smith + + + Occupation + + Sailor - Elizabeth Smith + + + Military Service + + Military Service - Elizabeth Smith + + + Residence + + Residence in Paris - Elizabeth Smith + + + Christening + + Christening of Smith, Nicholas + + + Education + + Education - Nicholas Smith + + + Occupation + + Carpenter - Nicholas Smith + + + Residence + + Residence in Madrid - Nicholas Smith + + + Immigration + + Immigration - Nicholas Smith + + + Retirement + + Retirement - Nicholas Smith + + + Education + + Education - Rebecca Smith + + + Graduation + + Graduation - Rebecca Smith + + + Occupation + + Engineer - Rebecca Smith + + + Residence + + Residence in Berlin - Rebecca Smith + + + Retirement + + Retirement - Rebecca Smith + + + Baptism + + Baptism of Smith, William + + + Graduation + + Graduation - William Smith + + + Occupation + + Soldier - William Smith + + + Occupation + + Merchant - Sharon Smith + + + Residence + + Residence in Prague - Sharon Smith + + + Burial + + Burial of Smith, Sharon + + + Baptism + + Baptism of Smith, Benjamin + + + Christening + + Christening of Smith, Benjamin + + + Education + + Education - Benjamin Smith + + + Residence + + Residence in Stockholm - Benjamin Smith + + + Immigration + + Immigration - Benjamin Smith + + + Retirement + + Retirement - Benjamin Smith + + + Education + + Education - Elizabeth Smith + + + Graduation + + Graduation - Elizabeth Smith + + + Occupation + + Blacksmith - Elizabeth Smith + + + Military Service + + Military Service - Elizabeth Smith + + + Residence + + Residence in Prague - Elizabeth Smith + + + Baptism + + Baptism of Smith, Larry + + + Graduation + + Graduation - Larry Smith + + + Occupation + + Doctor - Larry Smith + + + Military Service + + Military Service - Larry Smith + + + Residence + + Residence in Paris - Larry Smith + + + Immigration + + Immigration - Larry Smith + + + Baptism + + Baptism of Smith, Patricia + + + Occupation + + Soldier - Patricia Smith + + + Residence + + Residence in New York - Patricia Smith + + + Education + + Education - John Smith + + + Graduation + + Graduation - John Smith + + + Occupation + + Merchant - John Smith + + + Christening + + Christening of Smith, Linda + + + Education + + Education - Linda Smith + + + Graduation + + Graduation - Linda Smith + + + Occupation + + Blacksmith - Linda Smith + + + Emigration + + Emigration - Linda Smith + + + Immigration + + Immigration - Linda Smith + + + Retirement + + Retirement - Linda Smith + + + Baptism + + Baptism of Smith, Anthony + + + Christening + + Christening of Smith, Anthony + + + Occupation + + Carpenter - Anthony Smith + + + Residence + + Residence in Amsterdam - Anthony Smith + + + Immigration + + Immigration - Anthony Smith + + + Christening + + Christening of Smith, Shirley + + + Graduation + + Graduation - Shirley Smith + + + Military Service + + Military Service - Shirley Smith + + + Residence + + Residence in Madrid - Shirley Smith + + + Emigration + + Emigration - Shirley Smith + + + Retirement + + Retirement - Shirley Smith + + + Baptism + + Baptism of Smith, James + + + Education + + Education - James Smith + + + Graduation + + Graduation - James Smith + + + Occupation + + Nurse - James Smith + + + Military Service + + Military Service - James Smith + + + Residence + + Residence in Copenhagen - James Smith + + + Baptism + + Baptism of Smith, Stephen + + + Graduation + + Graduation - Stephen Smith + + + Occupation + + Lawyer - Stephen Smith + + + Military Service + + Military Service - Stephen Smith + + + Residence + + Residence in Copenhagen - Stephen Smith + + + Baptism + + Baptism of Smith, Ryan + + + Christening + + Christening of Smith, Ryan + + + Education + + Education - Ryan Smith + + + Graduation + + Graduation - Ryan Smith + + + Occupation + + Soldier - Ryan Smith + + + Military Service + + Military Service - Ryan Smith + + + Baptism + + Baptism of Smith, Margaret + + + Christening + + Christening of Smith, Margaret + + + Education + + Education - Margaret Smith + + + Graduation + + Graduation - Margaret Smith + + + Occupation + + Blacksmith - Margaret Smith + + + Military Service + + Military Service - Margaret Smith + + + Retirement + + Retirement - Margaret Smith + + + Baptism + + Baptism of Smith, Michael + + + Graduation + + Graduation - Michael Smith + + + Occupation + + Blacksmith - Michael Smith + + + Residence + + Residence in Warsaw - Michael Smith + + + Immigration + + Immigration - Michael Smith + + + Baptism + + Baptism of Smith, Emily + + + Graduation + + Graduation - Emily Smith + + + Occupation + + Carpenter - Emily Smith + + + Residence + + Residence in Copenhagen - Emily Smith + + + Education + + Education - Jessica Smith + + + Graduation + + Graduation - Jessica Smith + + + Occupation + + Farmer - Jessica Smith + + + Military Service + + Military Service - Jessica Smith + + + Residence + + Residence in Stockholm - Jessica Smith + + + Retirement + + Retirement - Jessica Smith + + + Baptism + + Baptism of Smith, Charles + + + Education + + Education - Charles Smith + + + Graduation + + Graduation - Charles Smith + + + Baptism + + Baptism of Smith, Mary + + + Education + + Education - Mary Smith + + + Graduation + + Graduation - Mary Smith + + + Occupation + + Doctor - Mary Smith + + + Residence + + Residence in Amsterdam - Mary Smith + + + Emigration + + Emigration - Mary Smith + + + Retirement + + Retirement - Mary Smith + + + Christening + + Christening of Smith, Richard + + + Education + + Education - Richard Smith + + + Graduation + + Graduation - Richard Smith + + + Occupation + + Merchant - Richard Smith + + + Christening + + Christening of Smith, Joshua + + + Graduation + + Graduation - Joshua Smith + + + Occupation + + Merchant - Joshua Smith + + + Residence + + Residence in Paris - Joshua Smith + + + Emigration + + Emigration - Joshua Smith + + + Baptism + + Baptism of Smith, Paul + + + Christening + + Christening of Smith, Paul + + + Education + + Education - Paul Smith + + + Graduation + + Graduation - Paul Smith + + + Occupation + + Blacksmith - Paul Smith + + + Military Service + + Military Service - Paul Smith + + + Residence + + Residence in Stockholm - Paul Smith + + + Immigration + + Immigration - Paul Smith + + + Christening + + Christening of Smith, Donna + + + Education + + Education - Donna Smith + + + Occupation + + Clerk - Donna Smith + + + Residence + + Residence in Madrid - Donna Smith + + + Immigration + + Immigration - Donna Smith + + + Education + + Education - Eric Smith + + + Graduation + + Graduation - Eric Smith + + + Military Service + + Military Service - Eric Smith + + + Residence + + Residence in London - Eric Smith + + + Immigration + + Immigration - Eric Smith + + + Retirement + + Retirement - Eric Smith + + + Baptism + + Baptism of Smith, Sandra + + + Education + + Education - Sandra Smith + + + Graduation + + Graduation - Sandra Smith + + + Occupation + + Blacksmith - Sandra Smith + + + Military Service + + Military Service - Sandra Smith + + + Residence + + Residence in Copenhagen - Sandra Smith + + + Baptism + + Baptism of Smith, Nicholas + + + Christening + + Christening of Smith, Nicholas + + + Graduation + + Graduation - Nicholas Smith + + + Occupation + + Teacher - Nicholas Smith + + + Emigration + + Emigration - Nicholas Smith + + + Retirement + + Retirement - Nicholas Smith + + + Education + + Education - Sandra Smith + + + Graduation + + Graduation - Sandra Smith + + + Occupation + + Doctor - Sandra Smith + + + Residence + + Residence in Copenhagen - Sandra Smith + + + Immigration + + Immigration - Sandra Smith + + + Education + + Education - Robert Smith + + + Occupation + + Clerk - Robert Smith + + + Military Service + + Military Service - Robert Smith + + + Immigration + + Immigration - Robert Smith + + + Baptism + + Baptism of Smith, Donna + + + Education + + Education - Donna Smith + + + Graduation + + Graduation - Donna Smith + + + Occupation + + Blacksmith - Donna Smith + + + Retirement + + Retirement - Donna Smith + + + Christening + + Christening of Smith, Richard + + + Education + + Education - Richard Smith + + + Occupation + + Nurse - Richard Smith + + + Military Service + + Military Service - Richard Smith + + + Residence + + Residence in Paris - Richard Smith + + + Retirement + + Retirement - Richard Smith + + + Education + + Education - Brenda Smith + + + Occupation + + Engineer - Brenda Smith + + + Military Service + + Military Service - Brenda Smith + + + Residence + + Residence in Stockholm - Brenda Smith + + + Immigration + + Immigration - Brenda Smith + + + Baptism + + Baptism of Smith, Timothy + + + Christening + + Christening of Smith, Timothy + + + Education + + Education - Timothy Smith + + + Graduation + + Graduation - Timothy Smith + + + Occupation + + Sailor - Timothy Smith + + + Military Service + + Military Service - Timothy Smith + + + Residence + + Residence in Stockholm - Timothy Smith + - + M John @@ -291,9 +1516,16 @@ + + + + + + + - + F Mary @@ -301,387 +1533,633 @@ + + + + + + + - + M - Timothy + Brandon Smith + + + + + + + - + F - Samantha + Amy Smith + + + + + + + + - + M - Anthony + Brandon Smith + + + + + - - F - - Christine - Smith - - - - - - - M - - Nicholas - Smith - - - - - - - F - - Pamela - Smith - - - - - - M - - Edward - Smith - - - - - - - F - - Shirley - Smith - - - - - - M - - John - Smith - - - - - - F - - Melissa - Smith - - - - - - M - - Stephen - Smith - - - - - - F - - Jennifer - Smith - - - - - - M - - Daniel - Smith - - - - - - F - - Rebecca - Smith - - - - - - M - - Justin - Smith - - - - - - F - - Sarah - Smith - - - - - - M - - Nicholas - Smith - - - - - - F - - Mary - Smith - - - - - - M - - Kevin - Smith - - - - - - F - - Stephanie - Smith - - - - - - M - - Nicholas - Smith - - - - - - M - - Matthew - Smith - - - - - - M - - Joshua - Smith - - - - - - F - - Kimberly - Smith - - - - - - M - - Andrew - Smith - - - - - - F - - Shirley - Smith - - - - - - M - - Timothy - Smith - - - - - - F - - Cynthia - Smith - - - - - - M - - Eric - Smith - - - - - - F - - Laura - Smith - - - - - - M - - Larry - Smith - - - - - - F - - Katherine - Smith - - - - - - M - - Brian - Smith - - - - - - M - - John - Smith - - - - - - F - - Brenda - Smith - - - - - - M - - Donald - Smith - - - - - - F - - Sharon - Smith - - - - - - M - - Gary - Smith - - - - - + F Betty Smith - - + + + + + + + + + + - + M - Joseph + Richard Smith - - + + + + + + + + - + + F + + Ashley + Smith + + + + + + + + + + + + M + + Michael + Smith + + + + + + + + + + + + F + + Elizabeth + Smith + + + + + + + + + + + + M + + Nicholas + Smith + + + + + + + + + + + + + F + + Rebecca + Smith + + + + + + + + + + + M + + William + Smith + + + + + + + + F Sharon Smith + + + + + + + + + M + + Benjamin + Smith + + + + + + + + + + + + F + + Elizabeth + Smith + + + + + + + + + + + M + + Larry + Smith + + + + + + + + + + + + F + + Patricia + Smith + + + + + + + + + M + + John + Smith + + + + + + + + + F + + Linda + Smith + + + + + + + + + + + + + M + + Anthony + Smith + + + + + + + + + + + F + + Shirley + Smith + + + + + + + + + + + + M + + James + Smith + + + + + + + + + + + + M + + Stephen + Smith + + + + + + + + + + + M + + Ryan + Smith + + + + + + + + + + + + F + + Margaret + Smith + + + + + + + + + + + + + M + + Michael + Smith + + + + + + + + + + + F + + Emily + Smith + + + + + + + + + + F + + Jessica + Smith + + + + + + + + + + + + M + + Charles + Smith + + + + + + + + + F + + Mary + Smith + + + + + + + + + + + + + M + + Richard + Smith + + + + + + + + + + M + + Joshua + Smith + + + + + + + + + + + M + + Paul + Smith + + + + + + + + + + + + + + F + + Donna + Smith + + + + + + + + + + + M + + Eric + Smith + + + + + + + + + + + + F + + Sandra + Smith + + + + + + + + + + + + M + + Nicholas + Smith + + + + + + + + + + + + F + + Sandra + Smith + + + + + + + + + + + M + + Robert + Smith + + + + + + + + + + F + + Donna + Smith + + + + + + + + + + + M + + Richard + Smith + + + + + + + + + + + + F + + Brenda + Smith + + + + + + + + + + M + + Timothy + Smith + + + + + + + + + - + @@ -702,7 +2180,7 @@ - + @@ -713,7 +2191,7 @@ - + @@ -721,29 +2199,29 @@ - - + - + + - - - + - + + + - + @@ -751,6 +2229,7 @@ + diff --git a/generate_demo_family.py b/generate_demo_family.py index 1919e13..114cc0d 100644 --- a/generate_demo_family.py +++ b/generate_demo_family.py @@ -6,13 +6,96 @@ Generate a huge demo family for Gramps testing import random from datetime import datetime, timedelta +# Set seed for deterministic event generation +random.seed(42) + # Generate unique handles def gen_handle(prefix, num): return f"_{prefix}{num:08d}" +# Event types to add +EVENT_TYPES = [ + ("Baptism", 0.7, 0, 2), # 70% chance, 0-2 years after birth + ("Christening", 0.5, 0, 1), # 50% chance, 0-1 years after birth + ("Education", 0.8, 5, 18), # 80% chance, 5-18 years after birth + ("Graduation", 0.6, 18, 25), # 60% chance, 18-25 years after birth + ("Occupation", 0.9, 18, 65), # 90% chance, 18-65 years after birth + ("Military Service", 0.3, 18, 30), # 30% chance, 18-30 years after birth + ("Residence", 0.7, 0, 80), # 70% chance, any time + ("Emigration", 0.2, 20, 50), # 20% chance, 20-50 years after birth + ("Immigration", 0.15, 20, 50), # 15% chance, 20-50 years after birth + ("Retirement", 0.4, 60, 75), # 40% chance, 60-75 years after birth + ("Burial", 0.6, None, None), # 60% chance if death exists, at death time + ("Cremation", 0.2, None, None), # 20% chance if death exists, at death time +] + +# Generate additional events for a person +def gen_additional_events(pid, first_name, surname, birth_year, death_year=None): + events = [] + event_id_offset = pid * 10 + 2 # Start after birth and death events + + for event_type, probability, min_years, max_years in EVENT_TYPES: + if random.random() > probability: + continue + + # Special handling for death-related events + if event_type in ("Burial", "Cremation"): + if not death_year: + continue + event_year = death_year + event_month = random.randint(1, 12) + event_day = random.randint(1, 28) + else: + if max_years is None: + continue + event_year = birth_year + random.randint(min_years, max_years) + if death_year and event_year > death_year: + continue + event_month = random.randint(1, 12) + event_day = random.randint(1, 28) + + event_handle = gen_handle("EVENT", event_id_offset) + event_id_offset += 1 + + # Generate description based on event type + if event_type == "Education": + description = f"Education - {first_name} {surname}" + elif event_type == "Graduation": + description = f"Graduation - {first_name} {surname}" + elif event_type == "Occupation": + occupations = ["Farmer", "Teacher", "Engineer", "Doctor", "Lawyer", "Merchant", + "Carpenter", "Blacksmith", "Sailor", "Soldier", "Clerk", "Nurse"] + occupation = random.choice(occupations) + description = f"{occupation} - {first_name} {surname}" + elif event_type == "Military Service": + description = f"Military Service - {first_name} {surname}" + elif event_type == "Residence": + places = ["New York", "London", "Paris", "Berlin", "Rome", "Madrid", "Amsterdam", + "Vienna", "Prague", "Warsaw", "Stockholm", "Copenhagen"] + place = random.choice(places) + description = f"Residence in {place} - {first_name} {surname}" + elif event_type == "Emigration": + description = f"Emigration - {first_name} {surname}" + elif event_type == "Immigration": + description = f"Immigration - {first_name} {surname}" + elif event_type == "Retirement": + description = f"Retirement - {first_name} {surname}" + else: + description = f"{event_type} of {surname}, {first_name}" + + event_xml = f""" + {event_type} + + {description} + +""" + events.append((event_handle, event_xml)) + + return events + # Generate a person def gen_person(pid, first_name, surname, birth_year, death_year=None, gender="M", - parentin_families=None, childof_families=None): + parentin_families=None, childof_families=None, reuse_additional_events=None): handle = gen_handle("PERSON", pid) birth_handle = gen_handle("EVENT", pid * 10) death_handle = gen_handle("EVENT", pid * 10 + 1) if death_year else None @@ -28,6 +111,18 @@ def gen_person(pid, first_name, surname, birth_year, death_year=None, gender="M" if death_handle: person_xml += f""" """ + + # Add additional events - reuse if provided, otherwise generate new + if reuse_additional_events is not None: + # reuse_additional_events is a list of (handle, xml) tuples + additional_events = reuse_additional_events + else: + additional_events = gen_additional_events(pid, first_name, surname, birth_year, death_year) + + for event_handle, _ in additional_events: + person_xml += f""" +""" + # Add parentin references (for fathers and mothers) if parentin_families: for family_handle in parentin_families: @@ -63,7 +158,10 @@ def gen_person(pid, first_name, surname, birth_year, death_year=None, gender="M" """ - return person_xml, birth_event, death_event + # Collect all additional events (return tuples for reuse, XML strings for output) + all_additional_events_xml = [event_xml for _, event_xml in additional_events] + + return person_xml, birth_event, death_event, all_additional_events_xml, additional_events # Generate a family def gen_family(fid, father_handle, mother_handle, marriage_year, children_handles): @@ -122,7 +220,7 @@ def main(): father_id = 1 father_handle = gen_handle("PERSON", father_id) main_family_handle = gen_handle("FAMILY", 1) - father_person, father_birth, father_death = gen_person( + father_person, father_birth, father_death, father_additional_xml, _ = gen_person( father_id, "John", "Smith", 1950, 2010, "M", parentin_families=[main_family_handle] ) @@ -130,15 +228,18 @@ def main(): # Mother: Mary Smith, born 1952, died 2015 mother_id = 2 mother_handle = gen_handle("PERSON", mother_id) - mother_person, mother_birth, mother_death = gen_person( + mother_person, mother_birth, mother_death, mother_additional_xml, _ = gen_person( mother_id, "Mary", "Smith", 1952, 2015, "F", parentin_families=[main_family_handle] ) + all_additional_events = father_additional_xml + mother_additional_xml + # Generate 15 children children = [] child_handles = [] child_events = [] + child_additional_events_map = {} # Store additional events by child_id child_id = 3 for i in range(15): @@ -148,7 +249,7 @@ def main(): death_year = birth_year + random.randint(60, 90) if random.random() < 0.3 else None # 30% chance of death child_handle = gen_handle("PERSON", child_id) - child_person, child_birth, child_death = gen_person( + child_person, child_birth, child_death, child_additional_xml, child_additional_tuples = gen_person( child_id, first_name, "Smith", birth_year, death_year, gender, childof_families=[main_family_handle] ) @@ -158,6 +259,9 @@ def main(): child_events.append(child_birth) if child_death: child_events.append(child_death) + # Store tuples for reuse when regenerating + child_additional_events_map[child_id] = child_additional_tuples + all_additional_events.extend(child_additional_xml) child_id += 1 # Generate family @@ -214,7 +318,7 @@ def main(): "birth": spouse_birth, "death": None, "gender": spouse_gender, "parentin": [child_family_handle], "childof": []} - spouse_person, spouse_birth_event, spouse_death_event = gen_person( + spouse_person, spouse_birth_event, spouse_death_event, spouse_additional_xml, _ = gen_person( grandchild_id, spouse_name, "Smith", spouse_birth, None, spouse_gender, parentin_families=[child_family_handle] ) @@ -222,6 +326,7 @@ def main(): grandchild_events.append(spouse_birth_event) if spouse_death_event: grandchild_events.append(spouse_death_event) + all_additional_events.extend(spouse_additional_xml) grandchild_id += 1 # Update parent to include parentin reference @@ -240,7 +345,7 @@ def main(): "birth": gchild_birth, "death": None, "gender": gchild_gender, "parentin": [], "childof": [child_family_handle]} - gchild_person, gchild_birth_event, gchild_death_event = gen_person( + gchild_person, gchild_birth_event, gchild_death_event, gchild_additional_xml, _ = gen_person( grandchild_id, gchild_name, "Smith", gchild_birth, None, gchild_gender, childof_families=[child_family_handle] ) @@ -249,6 +354,7 @@ def main(): grandchild_events.append(gchild_birth_event) if gchild_death_event: grandchild_events.append(gchild_death_event) + all_additional_events.extend(gchild_additional_xml) grandchild_id += 1 # Create family for this couple @@ -258,13 +364,17 @@ def main(): child_events.append(fam_marriage) # Regenerate children XMLs with updated family references + # We need to regenerate to update family references, but reuse the same events children = [] for i, child_handle in enumerate(child_handles): child_pid = 3 + i data = person_data[child_pid] - child_person, _, _ = gen_person( + # Reuse the original additional events to ensure consistency + original_additional_events = child_additional_events_map.get(child_pid, []) + child_person, _, _, _, _ = gen_person( child_pid, data["name"], data["surname"], data["birth"], data["death"], data["gender"], - parentin_families=data["parentin"], childof_families=data["childof"] + parentin_families=data["parentin"], childof_families=data["childof"], + reuse_additional_events=original_additional_events ) children.append(child_person) @@ -293,6 +403,8 @@ def main(): xml_content += event for event in grandchild_events: xml_content += event + for event in all_additional_events: + xml_content += event xml_content += """ @@ -316,6 +428,7 @@ def main(): with open("demo_family.gramps", "w", encoding="utf-8") as f: f.write(xml_content) + total_events = len(child_events) + len(grandchild_events) + len(all_additional_events) print(f"Generated demo_family.gramps with:") print(f" - 2 parents (John and Mary Smith)") print(f" - 15 children") @@ -323,6 +436,8 @@ def main(): print(f" - ~20 grandchildren") print(f" - Multiple families with marriage events") print(f" - Birth and death events for all") + print(f" - {len(all_additional_events)} additional events (Baptism, Education, Occupation, etc.)") + print(f" - Total events: {total_events}") if __name__ == "__main__": main()