Removed ability to add EvColumns directly to table - this causes some confusing effects and is not worth the trouble over building the table normally and reformatting with reformat_column.
This commit is contained in:
parent
8b8fbe8101
commit
3cc0d6ee16
1 changed files with 6 additions and 10 deletions
|
|
@ -757,7 +757,7 @@ class EvTable(object):
|
||||||
"""
|
"""
|
||||||
Table class.
|
Table class.
|
||||||
|
|
||||||
The table contains of a list of EvColumns, each consisting of EvCells so
|
The table holds a list of EvColumns, each consisting of EvCells so
|
||||||
that the result is a 2D matrix.
|
that the result is a 2D matrix.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -881,9 +881,8 @@ class EvTable(object):
|
||||||
# save options
|
# save options
|
||||||
self.options = kwargs
|
self.options = kwargs
|
||||||
|
|
||||||
# use the temporary table to generate the table on the fly, as a list of EvColumns.
|
# use the temporary table to generate the table on the fly, as a list of EvColumns
|
||||||
# If the input is not iterable we assume it is an EvColumn.
|
self.table = [EvColumn(*col, **kwargs) for col in table]
|
||||||
self.table = [col if isinstance(col, EvColumn) else EvColumn(*col, **kwargs) for col in table]
|
|
||||||
|
|
||||||
# this is the actual working table
|
# this is the actual working table
|
||||||
self.worktable = None
|
self.worktable = None
|
||||||
|
|
@ -1166,10 +1165,7 @@ class EvTable(object):
|
||||||
options = dict(self.options.items() + kwargs.items())
|
options = dict(self.options.items() + kwargs.items())
|
||||||
|
|
||||||
xpos = kwargs.get("xpos", None)
|
xpos = kwargs.get("xpos", None)
|
||||||
if args and isinstance(args[0], EvColumn):
|
column = EvColumn(*args, **options)
|
||||||
column = args[0]
|
|
||||||
else:
|
|
||||||
column = EvColumn(*args, **options)
|
|
||||||
htable = self.nrows
|
htable = self.nrows
|
||||||
excess = self.ncols - htable
|
excess = self.ncols - htable
|
||||||
|
|
||||||
|
|
@ -1295,11 +1291,11 @@ def _test():
|
||||||
table = EvTable("{yHeading1{n", "{gHeading2{n", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells")
|
table = EvTable("{yHeading1{n", "{gHeading2{n", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells")
|
||||||
table.add_column("{rThis is long data{n", "{bThis is even longer data{n")
|
table.add_column("{rThis is long data{n", "{bThis is even longer data{n")
|
||||||
table.add_row("This is a single row")
|
table.add_row("This is a single row")
|
||||||
col = EvColumn("Test1", "Test3", "Test4", width=10)
|
|
||||||
table.add_column(col)
|
|
||||||
print unicode(table)
|
print unicode(table)
|
||||||
table.reformat(width=50)
|
table.reformat(width=50)
|
||||||
print unicode(table)
|
print unicode(table)
|
||||||
|
table.reformat_column(3, width=30, align='r')
|
||||||
|
print unicode(table)
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue