jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.35k stars 154 forks source link

max_width should textwrap headers and max_table_width should textwrap the title #250

Closed RyanCigich closed 10 months ago

RyanCigich commented 1 year ago

Am I missing something in the max_width that prevents it from wrapping headers as well?

image

Also, should max_table_width wrap the title?

image

I also noticed that the max_width for column '1' is 20 in both tables, but in the 2 tables the wrapping for that column is not the same. Is that intended?

I'm trying to setup constraints that will keep the entire table within 100 characters wide and will accommodate any title/header/data length.

I had assumed that PrettyTable would handle this automagically after I set the min/max widths.

I'm not getting what I expected from the header, and I am extrapolating about the title and max_table_width.

This is all the debug logic to try and set the widths correctly

image

This is what I got:

+-----------------------------------------------------------------------------------------------------------------------------+
|  A REALLLLLLLLY LOOOOOOOOOOOOOOOOOOOOOONG title for funsies, that SHOULD determine the max width........................... |
+-------------------------------------------+---------------------+-------------------+-------------------+-------------------+
| a very long header that SHOULD be wrapped |          1          |         2         |         3         |         4         |
+-------------------------------------------+---------------------+-------------------+-------------------+-------------------+
|                     0                     |  a very long value  |         2         |         3         |         4         |
|                                           |    that SHOULD be   |                   |                   |                   |
|                                           |       wrapped.      |                   |                   |                   |
+-------------------------------------------+---------------------+-------------------+-------------------+-------------------+

This is what I wanted:

+--------------------+---------------------+-------------------+-------------------+-------------------+
|  A REALLLLLLLLY LOOOOOOOOOOOOOOOOOOOOOONG title for funsies, that SHOULD determine the max width     |
|  ...........................                                                                         |
+--------------------+---------------------+-------------------+-------------------+-------------------+
| a very long header |          1          |         2         |         3         |         4         |
|   that SHOULD be   |                     |                   |                   |                   |
|       wrapped      |                     |                   |                   |                   |
+--------------------+---------------------+-------------------+-------------------+-------------------+
|         0          |  a very long value  |         2         |         3         |         4         |
|                    |    that SHOULD be   |                   |                   |                   |
|                    |       wrapped.      |                   |                   |                   |
+--------------------+---------------------+-------------------+-------------------+-------------------+
RyanCigich commented 10 months ago

Immust have screwed up the formatting of this issue....It's not that important.