Tables now use ""dynamic page" allowing the contents to be anything that can be rendered ion a page.
Python CI / test (3.10) (push) Successful in 2m22s
Python CI / test (3.12) (push) Successful in 2m13s
Python CI / test (3.13) (push) Successful in 2m9s

This commit is contained in:
2025-11-11 18:10:47 +01:00
parent 889f27e1a3
commit 3bcd1bffb5
13 changed files with 2399 additions and 14 deletions
+18 -14
View File
@@ -452,27 +452,31 @@ class TableRenderer(Box):
"""
Calculate column widths and row heights for the table.
Uses the table optimizer for intelligent column width distribution.
Returns:
Tuple of (column_widths, row_heights_dict)
"""
# Determine number of columns (from first row)
num_columns = 0
all_rows = list(self._table.all_rows())
if all_rows:
first_row = all_rows[0][1]
num_columns = first_row.cell_count
from pyWebLayout.layout.table_optimizer import optimize_table_layout
if num_columns == 0:
all_rows = list(self._table.all_rows())
if not all_rows:
return ([100], {"header": 30, "body": 30, "footer": 30})
# Calculate column widths (equal distribution for now)
# Account for borders between columns
total_border_width = self._style.border_width * (num_columns + 1)
available_for_columns = self._available_width - total_border_width
column_width = max(50, available_for_columns // num_columns)
column_widths = [column_width] * num_columns
# Use optimizer for column widths!
column_widths = optimize_table_layout(
self._table,
self._available_width,
sample_size=5,
style=self._style
)
# Calculate row heights dynamically based on content
if not column_widths:
# Fallback if table is empty
column_widths = [100]
# Calculate row heights dynamically based on optimized column widths
header_height = self._calculate_row_height_for_section(
all_rows, "header", column_widths) if any(
1 for section, _ in all_rows if section == "header") else 0