From 833d16752a9ab2913e1b1978455eb4b878b76802 Mon Sep 17 00:00:00 2001 From: Mikael Capelle Date: Sat, 14 Jul 2018 17:56:26 +0200 Subject: [PATCH] Update. --- pyltk/tabular.py | 15 +++++++++------ pyltk/tikz/tikzpicture.py | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pyltk/tabular.py b/pyltk/tabular.py index 066fba1..f0fec9a 100644 --- a/pyltk/tabular.py +++ b/pyltk/tabular.py @@ -39,11 +39,12 @@ class row_element(element): class hline_element(row_element): - def __init__(self, parent=None): + def __init__(self, command='hline', parent=None): super().__init__([], parent) + self.command = command def content(self): - return '\\hline' + return '\\' + self.command # instance of hline element @@ -54,13 +55,13 @@ class tabular(element): """ Class representing a latex tabular. """ templates = { - 'content': """\\begin{{tabular}}{{{columns}}} + 'content': """\\begin{{{name}}}{{{columns}}} {inner} -\\end{{tabular}}""" +\\end{{{name}}}""" } def __init__(self, parent=None, rows=[], columns=None, - autowrap=False, label=None): + autowrap=False, label=None, name='tabular'): """ Create a tabular with given rows and column specification. Parameters: @@ -69,13 +70,14 @@ class tabular(element): """ super().__init__(parent, label=label) self.columns = columns + self.name = name self.autowrap = autowrap for row in rows: self.addrow(row) def addhline(self): """ Add a hline to the current tabular element. """ - self.addrow(hline_element(self), False) + self.addrow(hline_element(parent=self), False) def addrow(self, row, wrap=None, fmt=None): """ Add a row to the tabular. @@ -102,6 +104,7 @@ class tabular(element): def content(self): return self.fmt().format('content', { + 'name': self.name, 'columns': self.columns, 'inner': super().content() }) diff --git a/pyltk/tikz/tikzpicture.py b/pyltk/tikz/tikzpicture.py index 5067d9b..aa7efa0 100644 --- a/pyltk/tikz/tikzpicture.py +++ b/pyltk/tikz/tikzpicture.py @@ -7,15 +7,17 @@ class tikzpicture(element): """ Class representing a latex tikzfigure. """ templates = { - 'content': """\\begin{{tikzpicture}} + 'options': '[{content}]', + 'content': """\\begin{{tikzpicture}}{options} {inner} \\end{{tikzpicture}}""" } - def __init__(self, childrens=None, parent=None, label=None): - super().__init__(parent, childrens, label=label) + def __init__(self, childrens=None, parent=None, label=None, **kargs): + super().__init__(parent, childrens, label=label, **kargs) def content(self): return self.fmt().format('content', { - 'inner': super().content() + 'inner': super().content(), + 'options': self.format_options(self.options) })