Re: EuGTK:Column Widths in GtkTreeView
- Posted by irv Aug 30, 2019
- 852 views
Irv,
Is there a way to conform the column widths to a percentage of the available space?
For example, with three columns, I'd like their initial widths to be something like {80%,10%,10%}.
As it is now, the first column contents are making the first column push everything else off the side (and unseen).
Any ideas?
Sure, but if the text in the first column is too long, it will have to be ellipsized so it can fit into a reduced width.
There are "min width", "max width", and "fixed width" properties for the columns. The widths are in pixels, you could compute this by taking 80% of the main window width, or just choose a number that looks good.
Columns will have to be named e.g. create(GtkColumn,"name=col1,...") so that you can retrieve its renderer. Ellipsize modes are 0 = none, 1 = start, 2 = middle, 3 = end. Mode 2 works best here, I think.
set("col1->renderer","ellipsize",2) -- obtain and set column's renderer set(col1,"min width",300) -- set desired width in pixels set(col1,"resizable",TRUE) -- allow sliding the columns to reveal more of the text
If other columns contain data that doesn't fit, you may have to repeat the code above for those, too. Otherwise, they'll probably fit automatically.