evtable and evform supports ansi, with some limitations due to wrap not being supported by ANSIString at this point.
This commit is contained in:
parent
1886d455da
commit
021dca4ba7
3 changed files with 25 additions and 13 deletions
|
|
@ -17,6 +17,11 @@ has markers in it to denounce fields to fill. The markers map the
|
|||
absolute size of the field and will be filled with an evtable.Cell
|
||||
object when displaying the form.
|
||||
|
||||
Note, when printing examples with ANSI color, you need to wrap
|
||||
the output in unicode(), such as print unicode(form). This is
|
||||
due to a bug in the Python parser and the print statement.
|
||||
|
||||
|
||||
Example of input file testform.py:
|
||||
|
||||
FORMCHAR = "x"
|
||||
|
|
@ -87,7 +92,9 @@ Use as follows:
|
|||
# add the tables to the proper ids in the form
|
||||
form.map(tables={"A": tableA,
|
||||
"B": tableB}
|
||||
print form
|
||||
|
||||
# unicode is required since the example contains non-ascii characters
|
||||
print unicode(form)
|
||||
|
||||
This produces the following result:
|
||||
|
||||
|
|
@ -155,7 +162,6 @@ class EvForm(object):
|
|||
mapping so as to populate the fields with fixed-width
|
||||
Cell or Tablets.
|
||||
|
||||
|
||||
"""
|
||||
def __init__(self, filename=None, cells=None, tables=None, form=None, **kwargs):
|
||||
"""
|
||||
|
|
@ -401,6 +407,9 @@ class EvForm(object):
|
|||
|
||||
def __str__(self):
|
||||
"Prints the form"
|
||||
return "\n".join([to_str(line) for line in self.form])
|
||||
return ANSIString("\n").join([line for line in self.form])
|
||||
|
||||
def __unicode__(self):
|
||||
"prints the form"
|
||||
return unicode(ANSIString("\n").join([line for line in self.form]))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue