Comments (4)
Hi, thanks for this suggestion.
I have made changes to the SVN trunk such that it is now partially possible to
get the styles you want.
The "hrules" attribute, which could previously take values FRAME, ALL or NONE
can now also be set to HEADER, which prints a hrule only under the header, like
your first example.
In addition to the old "hrules" attribute, there is now also "vrules", which
can be take values FRAME, ALL or NONE.
By setting hrules=HEADER and vrules=NONE, along with horizontal_character="="
and junction_character="=", it should be possible to achieve the first example
table you gave.
By setting hrules=FRAME and vrules=FRAME, you can get something close to your
second example, the only difference being that you still won't have - as the
horizontal character for the frame and = as the horizontal character for the
header.
I may add the option for two different kind of horizontal characters, or I may
not, I am not sure yet. It seems harmless enough, but if I do that, then
somebody will want the ability to, e.g, make a table like this:
+=====+=====+
| Foo . Bar |
+-----+-----+
| 1 . 2 |
+=====+=====+
i.e. where the external rules are different from the internal rules, and then
if I do that somebody will want something else, and before you know it instead
of just horizontal_char, vertical_char and junction_char there will have to be
12 different attributes controlling the way lines are drawn to cover all the
edge cases...
In general I am not opposed to putting in stuff to let people tweak their
tables in all the little ways they want, but only if that doesn't make it
difficult for the majority of people to do simple things. If someone just
wants to use, say, "=" as their horizontal line everywhere, they should be able
to do that by setting one attribute, and should not be forced to set 3 or 4
attributes corresponding to all the different kinds of horizontal line if they
don't care about the differences.
Original comment by [email protected]
on 22 Jan 2013 at 12:43
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from prettytable.
First of all, thank you very much.
About the way prettytable works, I think that you should distinguish among:
* header line
* frame border
* horizontal rules
* vertical rules
I personally thing that controlling independently if these components of the
table should be showed or not is more important than using '&' for the
horizontal lines, which would produce a ugly table, plain and simple :).
I also think that if vrules==FRAME, then the code should not use the standard
junction_char but use the horizontal_char instead. The following code, for
example:
import prettytable as pt
p = pt.PrettyTable()
p.add_row(range(4))
p.add_row(range(5,9))
p.hrules=pt.ALL
p.vrules=pt.FRAME
print p
should produce the following result:
+---------------------------------------+
| Field 1 Field 2 Field 3 Field 4 |
+---------------------------------------+
| 0 1 2 3 |
+---------------------------------------+
| 5 6 7 8 |
+---------------------------------------+
instead of
+---------+---------+---------+---------+
| Field 1 Field 2 Field 3 Field 4 |
+---------+---------+---------+---------+
| 0 1 2 3 |
+---------+---------+---------+---------+
| 5 6 7 8 |
+---------+---------+---------+---------+
Original comment by [email protected]
on 22 Jan 2013 at 8:26
Attachments:
from prettytable.
Original comment by [email protected]
on 18 Feb 2013 at 7:12
- Changed title: Changes to border line styes [was: Requests for enhancement]
from prettytable.
I've made changes in trunk which fix the issue with printing spurious junction
characters as part of the horizontal lines when vrules is set to FRAME. Thanks
for pointing out this shortcoming.
Original comment by [email protected]
on 19 Feb 2013 at 5:38
from prettytable.
Related Issues (20)
- how to display "ambiguous" width in chinese character?
- table.min_width is broken when using PLAIN_COLUMNS style HOT 2
- Field alignment error when using "blessings" module HOT 1
- Adding colors to column values messes up the spacing HOT 2
- Setting float_format in **kwargs does not actually affect output - confusing behavior HOT 1
- Permissions are incorrect HOT 1
- Add date formatting for datetime etc instances HOT 3
- In get_string, end is eval before sortby
- HTML output is lacking borders, alignment
- Cannot print unicode characters, for example: degree symbol °
- Pandas DataFrame Table Factory HOT 3
- Upload new version to pypi
- xterm reset escape sequence not filtered HOT 2
- Support large tables in output HOT 1
- Prettytable 0.7.2 does not handle rowspan correctly
- Creating a PrettyTable inside a for. HOT 1
- Project Future and Plans HOT 4
- Export project to Github (or other git hosting project) HOT 2
- Stretching columns when the data are longer than the header
- Options not actually used in formatting rows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettytable.