tablepic 0.0.4__tar.gz → 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tablepic-0.0.4 → tablepic-0.0.5}/PKG-INFO +1 -1
- {tablepic-0.0.4 → tablepic-0.0.5}/pyproject.toml +1 -1
- {tablepic-0.0.4 → tablepic-0.0.5}/src/demo.py +1 -1
- {tablepic-0.0.4 → tablepic-0.0.5}/src/tablepic/main.py +8 -6
- {tablepic-0.0.4 → tablepic-0.0.5}/src/tablepic.egg-info/PKG-INFO +1 -1
- {tablepic-0.0.4 → tablepic-0.0.5}/LICENSE +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/README.md +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/readme_pypi.md +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/setup.cfg +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/src/tablepic/__init__.py +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/src/tablepic.egg-info/SOURCES.txt +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/src/tablepic.egg-info/dependency_links.txt +0 -0
- {tablepic-0.0.4 → tablepic-0.0.5}/src/tablepic.egg-info/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Author: xinyan
|
|
3
3
|
Date: 2023-06-13 17:12:25
|
|
4
4
|
LastEditors: xinyan
|
|
5
|
-
LastEditTime: 2023-
|
|
5
|
+
LastEditTime: 2023-07-05 11:35:06
|
|
6
6
|
Description: file content
|
|
7
7
|
'''
|
|
8
8
|
|
|
@@ -125,9 +125,10 @@ def get_data_info(data_dict:dict, key:str, i, j, v_default, v_type):
|
|
|
125
125
|
return result
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
def calculate_cell_width_height(data_dict:dict, font_path:str, cell_width:int, cell_height:int):
|
|
128
|
+
def calculate_cell_width_height(row_num:int, data_dict:dict, font_path:str, cell_width:int, cell_height:int):
|
|
129
129
|
col_width_dict = {}
|
|
130
130
|
row_height_dict = {}
|
|
131
|
+
header_row = row_num - len(data_dict['content'])
|
|
131
132
|
for i, data_line in enumerate(data_dict['content']):
|
|
132
133
|
for j, data_content in enumerate(data_line):
|
|
133
134
|
data_font = get_font(font_path, get_data_info(data_dict, 'font_size', i, j, 20, int))
|
|
@@ -135,8 +136,8 @@ def calculate_cell_width_height(data_dict:dict, font_path:str, cell_width:int, c
|
|
|
135
136
|
for item in data_content.split('\n'):
|
|
136
137
|
w, h = data_font.getbbox(item)[2:]
|
|
137
138
|
c_w = max(c_w, w) + 20
|
|
138
|
-
c_h = h * len(data_content.split('\n'))
|
|
139
|
-
row_height_dict[i] = max(row_height_dict.get(i, cell_height), c_h)
|
|
139
|
+
c_h = h * len(data_content.split('\n')) + 20
|
|
140
|
+
row_height_dict[i + header_row] = max(row_height_dict.get(i + header_row, cell_height), c_h)
|
|
140
141
|
col_width_dict[j] = max(col_width_dict.get(j, cell_width), c_w)
|
|
141
142
|
return col_width_dict, row_height_dict
|
|
142
143
|
|
|
@@ -199,8 +200,9 @@ def generate_table_pic(row_num:int, col_num:int, title_list:list, header_dict:di
|
|
|
199
200
|
:param font_path: str, optional parameter. Given the font path to set a new font for the text (including title, header, data).
|
|
200
201
|
"""
|
|
201
202
|
# Calculate the width for each column and the height for each row
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
default_col_width_dict, default_row_height_dict = calculate_cell_width_height(row_num, data_dict, font_path, cell_width, cell_height)
|
|
204
|
+
col_width_dict.update(default_col_width_dict)
|
|
205
|
+
row_height_dict.update(default_row_height_dict)
|
|
204
206
|
|
|
205
207
|
color_white = '#FFFFFF'
|
|
206
208
|
color_black = '#000000'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|