tksheet 7.2.1__py3-none-any.whl → 7.2.2__py3-none-any.whl
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.
- tksheet/__init__.py +1 -1
- tksheet/column_headers.py +247 -201
- tksheet/main_table.py +70 -64
- tksheet/row_index.py +234 -196
- tksheet/sheet.py +79 -46
- tksheet/top_left_rectangle.py +7 -2
- {tksheet-7.2.1.dist-info → tksheet-7.2.2.dist-info}/METADATA +6 -4
- tksheet-7.2.2.dist-info/RECORD +20 -0
- tksheet-7.2.1.dist-info/RECORD +0 -20
- {tksheet-7.2.1.dist-info → tksheet-7.2.2.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.2.1.dist-info → tksheet-7.2.2.dist-info}/WHEEL +0 -0
- {tksheet-7.2.1.dist-info → tksheet-7.2.2.dist-info}/top_level.txt +0 -0
tksheet/main_table.py
CHANGED
@@ -3642,7 +3642,7 @@ class MainTable(tk.Canvas):
|
|
3642
3642
|
return w + self.table_txt_height, h
|
3643
3643
|
return w, h
|
3644
3644
|
|
3645
|
-
def set_cell_size_to_text(self, r, c,
|
3645
|
+
def set_cell_size_to_text(self, r, c, only_if_too_small=False, redraw: bool = True, run_binding=False):
|
3646
3646
|
min_column_width = int(self.min_column_width)
|
3647
3647
|
min_rh = int(self.min_row_height)
|
3648
3648
|
w = min_column_width
|
@@ -3662,7 +3662,7 @@ class MainTable(tk.Canvas):
|
|
3662
3662
|
w = int(self.max_column_width)
|
3663
3663
|
cell_needs_resize_w = False
|
3664
3664
|
cell_needs_resize_h = False
|
3665
|
-
if
|
3665
|
+
if only_if_too_small:
|
3666
3666
|
if w > self.col_positions[c + 1] - self.col_positions[c]:
|
3667
3667
|
cell_needs_resize_w = True
|
3668
3668
|
if h > self.row_positions[r + 1] - self.row_positions[r]:
|
@@ -3792,24 +3792,26 @@ class MainTable(tk.Canvas):
|
|
3792
3792
|
|
3793
3793
|
def reset_col_positions(self, ncols: int | None = None):
|
3794
3794
|
colpos = self.PAR.ops.default_column_width
|
3795
|
-
if
|
3796
|
-
self.set_col_positions(itr=(colpos
|
3795
|
+
if isinstance(ncols, int):
|
3796
|
+
self.set_col_positions(itr=repeat(colpos, ncols))
|
3797
3797
|
else:
|
3798
|
-
self.
|
3799
|
-
itr=(colpos
|
3800
|
-
|
3798
|
+
if self.all_columns_displayed:
|
3799
|
+
self.set_col_positions(itr=repeat(colpos, self.total_data_cols()))
|
3800
|
+
else:
|
3801
|
+
self.set_col_positions(itr=repeat(colpos, len(self.displayed_columns)))
|
3801
3802
|
|
3802
3803
|
def set_row_positions(self, itr: Iterator[float]) -> None:
|
3803
3804
|
self.row_positions = list(accumulate(chain([0], itr)))
|
3804
3805
|
|
3805
3806
|
def reset_row_positions(self, nrows: int | None = None):
|
3806
3807
|
rowpos = self.get_default_row_height()
|
3807
|
-
if
|
3808
|
-
self.set_row_positions(itr=(rowpos
|
3808
|
+
if isinstance(nrows, int):
|
3809
|
+
self.set_row_positions(itr=repeat(rowpos, nrows))
|
3809
3810
|
else:
|
3810
|
-
self.
|
3811
|
-
itr=(rowpos
|
3812
|
-
|
3811
|
+
if self.all_rows_displayed:
|
3812
|
+
self.set_row_positions(itr=repeat(rowpos, self.total_data_rows()))
|
3813
|
+
else:
|
3814
|
+
self.set_row_positions(itr=repeat(rowpos, len(self.displayed_rows)))
|
3813
3815
|
|
3814
3816
|
def del_col_position(self, idx: int, deselect_all: bool = False):
|
3815
3817
|
if deselect_all:
|
@@ -4339,7 +4341,7 @@ class MainTable(tk.Canvas):
|
|
4339
4341
|
self.set_row_positions(
|
4340
4342
|
itr=chain(
|
4341
4343
|
self.gen_row_heights(),
|
4342
|
-
(default_row_height
|
4344
|
+
repeat(default_row_height, len(self.row_positions) - 1, maxrn + 1),
|
4343
4345
|
)
|
4344
4346
|
)
|
4345
4347
|
if isinstance(self._headers, list) and header:
|
@@ -4474,7 +4476,7 @@ class MainTable(tk.Canvas):
|
|
4474
4476
|
self.set_col_positions(
|
4475
4477
|
itr=chain(
|
4476
4478
|
self.gen_column_widths(),
|
4477
|
-
(self.PAR.ops.default_column_width
|
4479
|
+
repeat(self.PAR.ops.default_column_width, len(self.col_positions) - 1, maxcn + 1),
|
4478
4480
|
)
|
4479
4481
|
)
|
4480
4482
|
if push_ops:
|
@@ -5015,19 +5017,21 @@ class MainTable(tk.Canvas):
|
|
5015
5017
|
self.canvasy(self.winfo_height()),
|
5016
5018
|
)
|
5017
5019
|
|
5018
|
-
|
5019
|
-
|
5020
|
-
|
5021
|
-
|
5022
|
-
|
5023
|
-
|
5024
|
-
|
5025
|
-
|
5026
|
-
|
5027
|
-
|
5028
|
-
|
5029
|
-
|
5030
|
-
|
5020
|
+
@property
|
5021
|
+
def visible_text_rows(self) -> tuple[int, int]:
|
5022
|
+
start = bisect_left(self.row_positions, self.canvasy(0))
|
5023
|
+
end = bisect_right(self.row_positions, self.canvasy(self.winfo_height()))
|
5024
|
+
start = start - 1 if start else start
|
5025
|
+
end = end - 1 if end == len(self.row_positions) else end
|
5026
|
+
return start, end
|
5027
|
+
|
5028
|
+
@property
|
5029
|
+
def visible_text_columns(self) -> tuple[int, int]:
|
5030
|
+
start = bisect_left(self.col_positions, self.canvasx(0))
|
5031
|
+
end = bisect_right(self.col_positions, self.canvasx(self.winfo_width()))
|
5032
|
+
start = start - 1 if start else start
|
5033
|
+
end = end - 1 if end == len(self.col_positions) else end
|
5034
|
+
return start, end
|
5031
5035
|
|
5032
5036
|
def redraw_highlight_get_text_fg(
|
5033
5037
|
self,
|
@@ -5374,21 +5378,26 @@ class MainTable(tk.Canvas):
|
|
5374
5378
|
self.RI.configure_scrollregion(last_row_line_pos)
|
5375
5379
|
if setting_views:
|
5376
5380
|
return False
|
5381
|
+
scrollpos_top = self.canvasy(0)
|
5377
5382
|
scrollpos_bot = self.canvasy(can_height)
|
5378
|
-
end_row = bisect_right(self.row_positions, scrollpos_bot)
|
5379
|
-
if not scrollpos_bot >= self.row_positions[-1]:
|
5380
|
-
end_row += 1
|
5381
5383
|
scrollpos_left = self.canvasx(0)
|
5382
|
-
scrollpos_top = self.canvasy(0)
|
5383
5384
|
scrollpos_right = self.canvasx(can_width)
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5385
|
+
|
5386
|
+
grid_start_row = bisect_left(self.row_positions, scrollpos_top)
|
5387
|
+
grid_end_row = bisect_right(self.row_positions, scrollpos_bot)
|
5388
|
+
grid_start_col = bisect_left(self.col_positions, scrollpos_left)
|
5389
|
+
grid_end_col = bisect_right(self.col_positions, scrollpos_right)
|
5390
|
+
|
5391
|
+
text_start_row = grid_start_row - 1 if grid_start_row else grid_start_row
|
5392
|
+
text_end_row = grid_end_row - 1 if grid_end_row == len(self.row_positions) else grid_end_row
|
5393
|
+
text_start_col = grid_start_col - 1 if grid_start_col else grid_start_col
|
5394
|
+
text_end_col = grid_end_col - 1 if grid_end_col == len(self.col_positions) else grid_end_col
|
5395
|
+
|
5387
5396
|
changed_w = False
|
5388
5397
|
if self.PAR.ops.auto_resize_row_index and redraw_row_index and self.show_index:
|
5389
5398
|
changed_w = self.RI.auto_set_index_width(
|
5390
|
-
end_row=
|
5391
|
-
only_rows=[self.datarn(r) for r in range(
|
5399
|
+
end_row=grid_end_row,
|
5400
|
+
only_rows=[self.datarn(r) for r in range(text_start_row, text_end_row)],
|
5392
5401
|
)
|
5393
5402
|
if resized_cols or resized_rows or changed_w:
|
5394
5403
|
self.recreate_all_selection_boxes()
|
@@ -5408,8 +5417,6 @@ class MainTable(tk.Canvas):
|
|
5408
5417
|
self.disp_dropdown = {}
|
5409
5418
|
self.hidd_checkbox.update(self.disp_checkbox)
|
5410
5419
|
self.disp_checkbox = {}
|
5411
|
-
if not scrollpos_right >= self.col_positions[-1]:
|
5412
|
-
end_col += 1
|
5413
5420
|
if last_col_line_pos > scrollpos_right:
|
5414
5421
|
x_stop = scrollpos_right
|
5415
5422
|
else:
|
@@ -5439,7 +5446,7 @@ class MainTable(tk.Canvas):
|
|
5439
5446
|
self.canvasx(0) - 1,
|
5440
5447
|
self.row_positions[r + 1] if len(self.row_positions) - 1 > r else self.row_positions[r],
|
5441
5448
|
)
|
5442
|
-
for r in range(
|
5449
|
+
for r in range(grid_start_row, grid_end_row)
|
5443
5450
|
]
|
5444
5451
|
)
|
5445
5452
|
)
|
@@ -5471,7 +5478,7 @@ class MainTable(tk.Canvas):
|
|
5471
5478
|
self.col_positions[c + 1] if len(self.col_positions) - 1 > c else self.col_positions[c],
|
5472
5479
|
scrollpos_top - 1,
|
5473
5480
|
)
|
5474
|
-
for c in range(
|
5481
|
+
for c in range(grid_start_col, grid_end_col)
|
5475
5482
|
]
|
5476
5483
|
)
|
5477
5484
|
)
|
@@ -5482,13 +5489,8 @@ class MainTable(tk.Canvas):
|
|
5482
5489
|
width=1,
|
5483
5490
|
tag="g",
|
5484
5491
|
)
|
5485
|
-
if start_row > 0:
|
5486
|
-
start_row -= 1
|
5487
|
-
if start_col > 0:
|
5488
|
-
start_col -= 1
|
5489
|
-
end_row -= 1
|
5490
5492
|
if redraw_table:
|
5491
|
-
selections = self.get_redraw_selections(
|
5493
|
+
selections = self.get_redraw_selections(text_start_row, grid_end_row, text_start_col, grid_end_col)
|
5492
5494
|
c_2 = (
|
5493
5495
|
self.PAR.ops.table_selected_cells_bg
|
5494
5496
|
if self.PAR.ops.table_selected_cells_bg.startswith("#")
|
@@ -5507,10 +5509,10 @@ class MainTable(tk.Canvas):
|
|
5507
5509
|
else color_map[self.PAR.ops.table_selected_rows_bg]
|
5508
5510
|
)
|
5509
5511
|
c_4_ = (int(c_4[1:3], 16), int(c_4[3:5], 16), int(c_4[5:], 16))
|
5510
|
-
rows_ = tuple(range(
|
5512
|
+
rows_ = tuple(range(text_start_row, text_end_row))
|
5511
5513
|
font = self.PAR.ops.table_font
|
5512
5514
|
dd_coords = self.dropdown.get_coords()
|
5513
|
-
for c in range(
|
5515
|
+
for c in range(text_start_col, text_end_col):
|
5514
5516
|
for r in rows_:
|
5515
5517
|
rtopgridln = self.row_positions[r]
|
5516
5518
|
rbotgridln = self.row_positions[r + 1]
|
@@ -5718,23 +5720,27 @@ class MainTable(tk.Canvas):
|
|
5718
5720
|
self.tag_raise(self.selected.iid)
|
5719
5721
|
if redraw_header and self.show_header:
|
5720
5722
|
self.CH.redraw_grid_and_text(
|
5721
|
-
last_col_line_pos,
|
5722
|
-
scrollpos_left,
|
5723
|
-
x_stop,
|
5724
|
-
|
5725
|
-
|
5726
|
-
|
5727
|
-
|
5723
|
+
last_col_line_pos=last_col_line_pos,
|
5724
|
+
scrollpos_left=scrollpos_left,
|
5725
|
+
x_stop=x_stop,
|
5726
|
+
grid_start_col=grid_start_col,
|
5727
|
+
grid_end_col=grid_end_col,
|
5728
|
+
text_start_col=text_start_col,
|
5729
|
+
text_end_col=text_end_col,
|
5730
|
+
scrollpos_right=scrollpos_right,
|
5731
|
+
col_pos_exists=col_pos_exists,
|
5728
5732
|
)
|
5729
5733
|
if redraw_row_index and self.show_index:
|
5730
5734
|
self.RI.redraw_grid_and_text(
|
5731
|
-
last_row_line_pos,
|
5732
|
-
scrollpos_top,
|
5733
|
-
y_stop,
|
5734
|
-
|
5735
|
-
|
5736
|
-
|
5737
|
-
|
5735
|
+
last_row_line_pos=last_row_line_pos,
|
5736
|
+
scrollpos_top=scrollpos_top,
|
5737
|
+
y_stop=y_stop,
|
5738
|
+
grid_start_row=grid_start_row,
|
5739
|
+
grid_end_row=grid_end_row,
|
5740
|
+
text_start_row=text_start_row,
|
5741
|
+
text_end_row=text_end_row,
|
5742
|
+
scrollpos_bot=scrollpos_bot,
|
5743
|
+
row_pos_exists=row_pos_exists,
|
5738
5744
|
)
|
5739
5745
|
event_data = {"sheetname": "", "header": redraw_header, "row_index": redraw_row_index, "table": redraw_table}
|
5740
5746
|
self.PAR.emit_event("<<SheetRedrawn>>", data=event_data)
|
@@ -6489,7 +6495,7 @@ class MainTable(tk.Canvas):
|
|
6489
6495
|
text = text if isinstance(text, str) else f"{text}"
|
6490
6496
|
text = "" if text is None else text
|
6491
6497
|
if self.PAR.ops.cell_auto_resize_enabled:
|
6492
|
-
self.set_cell_size_to_text(r, c,
|
6498
|
+
self.set_cell_size_to_text(r, c, only_if_too_small=True, redraw=True, run_binding=True)
|
6493
6499
|
if self.text_editor.open and (r, c) == self.text_editor.coords:
|
6494
6500
|
self.text_editor.window.set_text(self.text_editor.get() + "" if not isinstance(text, str) else text)
|
6495
6501
|
return
|
@@ -7106,7 +7112,7 @@ class MainTable(tk.Canvas):
|
|
7106
7112
|
self.undo_stack.append(pickled_event_dict(event_data))
|
7107
7113
|
self.set_cell_data(datarn, datacn, value)
|
7108
7114
|
if cell_resize and self.PAR.ops.cell_auto_resize_enabled:
|
7109
|
-
self.set_cell_size_to_text(r, c,
|
7115
|
+
self.set_cell_size_to_text(r, c, only_if_too_small=True, redraw=redraw, run_binding=True)
|
7110
7116
|
self.sheet_modified(event_data)
|
7111
7117
|
return True
|
7112
7118
|
return False
|