diff options
Diffstat (limited to 'src/union.py')
-rw-r--r-- | src/union.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/union.py b/src/union.py index fdfff51..689b59f 100644 --- a/src/union.py +++ b/src/union.py @@ -11,9 +11,9 @@ const._union_color = (0, 0, 0) class Union: "Class to process union between two persons" - def __init__(self, dad, mum): + def __init__(self, dad, mum, id=None): "Constructor, init dad, mum and childs" - self.id = Guid().newid() + self.id = Guid().newid(id) self.dad = dad dad.append_union(self) self.mum = mum @@ -30,7 +30,7 @@ class Union: def tostring(self, level=1): "Translate to a formatted string, tree is horizontal" - str = 'U{0}\n'.format(self.id) + str = "U"+str(self.id)+"\n" for c in self.childs: str += c.tostring(level+1) + '\n' @@ -81,6 +81,11 @@ class Union: return self.dad + def child_count(self): + "Compute number of childs" + return len(self.childs) + + def draw(self, gc, pc): "Draw person and its subtree in the graphical context" |