uri-mog / prettytable

Automatically exported from code.google.com/p/prettytable
Other
0 stars 0 forks source link

Option to set column min width #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I would like to request option to set minimum column width

Sample:
x.set_field_names(["City name", "Area"])
x.add_row(["Adelaide",1295])
x.add_row(["Brisbane",5905])
x.align["City name"] = 'l'
x.min_width["City name"] = 30

Will end:
+--------------------------------+------+
| City name                      | Area |
+--------------------------------+------+
| Adelaide                       | 1295 |
| Brisbane                       | 5905 |
+--------------------------------+------+

or

set table min width and provide column to expand:
x.min_width(60, "City name")

Will give:
+---------------------------------------------------+------+
| City name                                         | Area |
+---------------------------------------------------+------+
| Adelaide                                          | 1295 |
| Brisbane                                          | 5905 |
+---------------------------------------------------+------+

Best regards

Original issue reported on code.google.com by matri...@gmail.com on 5 Oct 2012 at 6:45

GoogleCodeExporter commented 8 years ago
Thanks for this suggestion.  I like it, and will endeavour to add it to a 
future version.

I am planning on releasing 0.7 later today, since it has been a long time and 
many fixes/improvements have accumulated but are not seeing widespread use.

I think I will put your request off until the next release, though, since the 
code to do with table size is surprisingly subtle, and since I haven't worked 
on pt in a long time I'm not currently "in the zone" and worry that it might 
take me a while to get it right, and I don't want to delay 0.7.

Hopefully you won't have to wait too long.

Original comment by luke@maurits.id.au on 21 Jan 2013 at 10:29

GoogleCodeExporter commented 8 years ago
Thank you.

Best regards

Original comment by matri...@gmail.com on 21 Jan 2013 at 11:06

GoogleCodeExporter commented 8 years ago
Hi there.  This feature is now implemented in trunk.  It works the first way 
you suggested, i.e. you can set table.min_width["fieldname"] to set minimum 
widths for individual fields.

You can also set table.min_table_width=80, say, to set a minimum width for the 
whole table.  However, at the moment you can't specify a particular column to 
expand.  Instead all columns are expanded in proportion to their pre-expansion 
width to take up the extra space.

Please feel free to test these features and give me any feedback.  Sorry for 
the long wait!

Original comment by luke@maurits.id.au on 7 Oct 2013 at 8:46