tksheet 7.1.22__py3-none-any.whl → 7.1.24__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/main_table.py +77 -58
- tksheet/row_index.py +18 -19
- tksheet/sheet.py +59 -21
- tksheet/sheet_options.py +2 -1
- tksheet/top_left_rectangle.py +3 -2
- {tksheet-7.1.22.dist-info → tksheet-7.1.24.dist-info}/METADATA +1 -1
- tksheet-7.1.24.dist-info/RECORD +20 -0
- tksheet-7.1.22.dist-info/RECORD +0 -20
- {tksheet-7.1.22.dist-info → tksheet-7.1.24.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.1.22.dist-info → tksheet-7.1.24.dist-info}/WHEEL +0 -0
- {tksheet-7.1.22.dist-info → tksheet-7.1.24.dist-info}/top_level.txt +0 -0
tksheet/__init__.py
CHANGED
tksheet/main_table.py
CHANGED
@@ -683,9 +683,9 @@ class MainTable(tk.Canvas):
|
|
683
683
|
return event_data
|
684
684
|
|
685
685
|
def ctrl_v(self, event: object = None, validation: bool = True) -> None | EventDataDict:
|
686
|
-
if not self.PAR.ops.
|
687
|
-
|
688
|
-
):
|
686
|
+
if not self.PAR.ops.paste_can_expand_x and len(self.col_positions) == 1:
|
687
|
+
return
|
688
|
+
if not self.PAR.ops.paste_can_expand_y and len(self.row_positions) == 1:
|
689
689
|
return
|
690
690
|
event_data = event_dict(
|
691
691
|
name="edit_table",
|
@@ -696,7 +696,7 @@ class MainTable(tk.Canvas):
|
|
696
696
|
if self.selected:
|
697
697
|
selected_r = self.selected.row
|
698
698
|
selected_c = self.selected.column
|
699
|
-
elif not self.selected and not self.PAR.ops.
|
699
|
+
elif not self.selected and not self.PAR.ops.paste_can_expand_x and not self.PAR.ops.paste_can_expand_y:
|
700
700
|
return
|
701
701
|
else:
|
702
702
|
if not self.data:
|
@@ -721,32 +721,31 @@ class MainTable(tk.Canvas):
|
|
721
721
|
for rn, r in enumerate(data):
|
722
722
|
if len(r) < new_data_numcols:
|
723
723
|
data[rn] += list(repeat("", new_data_numcols - len(r)))
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
724
|
+
if self.selected:
|
725
|
+
(
|
726
|
+
lastbox_r1,
|
727
|
+
lastbox_c1,
|
728
|
+
lastbox_r2,
|
729
|
+
lastbox_c2,
|
730
|
+
) = self.selection_boxes[self.selected.fill_iid].coords
|
731
|
+
lastbox_numrows = lastbox_r2 - lastbox_r1
|
732
|
+
lastbox_numcols = lastbox_c2 - lastbox_c1
|
733
|
+
if lastbox_numrows > new_data_numrows and not lastbox_numrows % new_data_numrows:
|
734
|
+
nd = []
|
735
|
+
for _ in range(int(lastbox_numrows / new_data_numrows)):
|
736
|
+
nd.extend(r.copy() for r in data)
|
737
|
+
data.extend(nd)
|
738
|
+
new_data_numrows *= int(lastbox_numrows / new_data_numrows)
|
739
|
+
if lastbox_numcols > new_data_numcols and not lastbox_numcols % new_data_numcols:
|
740
|
+
for rn, r in enumerate(data):
|
741
|
+
for _ in range(int(lastbox_numcols / new_data_numcols)):
|
742
|
+
data[rn].extend(r.copy())
|
743
|
+
new_data_numcols *= int(lastbox_numcols / new_data_numcols)
|
744
744
|
event_data["data"] = data
|
745
745
|
added_rows = 0
|
746
746
|
added_cols = 0
|
747
747
|
total_data_cols = None
|
748
|
-
if self.PAR.ops.
|
749
|
-
# determine number of columns and/or rows to add to sheet
|
748
|
+
if self.PAR.ops.paste_can_expand_x:
|
750
749
|
if selected_c + new_data_numcols > len(self.col_positions) - 1:
|
751
750
|
total_data_cols = self.equalize_data_row_lengths()
|
752
751
|
added_cols = selected_c + new_data_numcols - len(self.col_positions) + 1
|
@@ -755,6 +754,7 @@ class MainTable(tk.Canvas):
|
|
755
754
|
and self.PAR.ops.paste_insert_column_limit < len(self.col_positions) - 1 + added_cols
|
756
755
|
):
|
757
756
|
added_cols = self.PAR.ops.paste_insert_column_limit - len(self.col_positions) - 1
|
757
|
+
if self.PAR.ops.paste_can_expand_y:
|
758
758
|
if selected_r + new_data_numrows > len(self.row_positions) - 1:
|
759
759
|
added_rows = selected_r + new_data_numrows - len(self.row_positions) + 1
|
760
760
|
if (
|
@@ -772,6 +772,7 @@ class MainTable(tk.Canvas):
|
|
772
772
|
adjusted_new_data_numrows = new_data_numrows
|
773
773
|
selected_r_adjusted_new_data_numrows = selected_r + adjusted_new_data_numrows
|
774
774
|
selected_c_adjusted_new_data_numcols = selected_c + adjusted_new_data_numcols
|
775
|
+
endrow = selected_r_adjusted_new_data_numrows
|
775
776
|
boxes = {
|
776
777
|
(
|
777
778
|
selected_r,
|
@@ -807,7 +808,7 @@ class MainTable(tk.Canvas):
|
|
807
808
|
value=val,
|
808
809
|
event_data=event_data,
|
809
810
|
)
|
810
|
-
if added_rows
|
811
|
+
if added_rows:
|
811
812
|
ctr = 0
|
812
813
|
data_ins_row = len(self.data)
|
813
814
|
displayed_ins_row = len(self.row_positions) - 1
|
@@ -817,6 +818,7 @@ class MainTable(tk.Canvas):
|
|
817
818
|
data_ins_row=data_ins_row,
|
818
819
|
displayed_ins_row=displayed_ins_row,
|
819
820
|
numrows=added_rows,
|
821
|
+
total_data_cols=total_data_cols,
|
820
822
|
)
|
821
823
|
for ndr, r in zip(
|
822
824
|
range(
|
@@ -851,8 +853,10 @@ class MainTable(tk.Canvas):
|
|
851
853
|
row_heights=row_heights,
|
852
854
|
event_data=event_data,
|
853
855
|
)
|
854
|
-
if added_cols
|
856
|
+
if added_cols:
|
855
857
|
ctr = 0
|
858
|
+
if total_data_cols is None:
|
859
|
+
total_data_cols = self.total_data_cols()
|
856
860
|
data_ins_col = total_data_cols
|
857
861
|
displayed_ins_col = len(self.col_positions) - 1
|
858
862
|
columns, headers, column_widths = self.get_args_for_add_columns(
|
@@ -860,10 +864,15 @@ class MainTable(tk.Canvas):
|
|
860
864
|
displayed_ins_col=displayed_ins_col,
|
861
865
|
numcols=added_cols,
|
862
866
|
)
|
867
|
+
# only add the extra rows if expand_y is allowed
|
868
|
+
if self.PAR.ops.paste_can_expand_x and self.PAR.ops.paste_can_expand_y:
|
869
|
+
endrow = selected_r + new_data_numrows
|
870
|
+
else:
|
871
|
+
endrow = selected_r + adjusted_new_data_numrows
|
863
872
|
for ndr, r in enumerate(
|
864
873
|
range(
|
865
874
|
selected_r,
|
866
|
-
|
875
|
+
endrow,
|
867
876
|
)
|
868
877
|
):
|
869
878
|
for ndc, c in zip(
|
@@ -896,11 +905,19 @@ class MainTable(tk.Canvas):
|
|
896
905
|
self.deselect("all", redraw=False)
|
897
906
|
if event_data["cells"]["table"] or event_data["added"]["rows"] or event_data["added"]["columns"]:
|
898
907
|
self.undo_stack.append(pickled_event_dict(event_data))
|
908
|
+
if added_rows:
|
909
|
+
selboxr = selected_r + new_data_numrows
|
910
|
+
else:
|
911
|
+
selboxr = selected_r_adjusted_new_data_numrows
|
912
|
+
if added_cols:
|
913
|
+
selboxc = selected_c + new_data_numcols
|
914
|
+
else:
|
915
|
+
selboxc = selected_c_adjusted_new_data_numcols
|
899
916
|
self.create_selection_box(
|
900
917
|
selected_r,
|
901
918
|
selected_c,
|
902
|
-
|
903
|
-
|
919
|
+
selboxr,
|
920
|
+
selboxc,
|
904
921
|
"cells",
|
905
922
|
run_binding=True,
|
906
923
|
)
|
@@ -1260,7 +1277,7 @@ class MainTable(tk.Canvas):
|
|
1260
1277
|
len(self.row_positions) - 1,
|
1261
1278
|
max(data_new_idxs.values(), default=0),
|
1262
1279
|
)
|
1263
|
-
|
1280
|
+
self.fix_data_len(totalrows)
|
1264
1281
|
if event_data is None:
|
1265
1282
|
event_data = event_dict(
|
1266
1283
|
name="move_rows",
|
@@ -2421,7 +2438,7 @@ class MainTable(tk.Canvas):
|
|
2421
2438
|
command=self.ctrl_v,
|
2422
2439
|
**mnkwgs,
|
2423
2440
|
)
|
2424
|
-
if self.PAR.ops.
|
2441
|
+
if self.PAR.ops.paste_can_expand_x or self.PAR.ops.paste_can_expand_y:
|
2425
2442
|
self.menu_add_command(
|
2426
2443
|
self.empty_rc_popup_menu,
|
2427
2444
|
label=self.PAR.ops.paste_label,
|
@@ -4295,13 +4312,12 @@ class MainTable(tk.Canvas):
|
|
4295
4312
|
column_widths,
|
4296
4313
|
)
|
4297
4314
|
)
|
4298
|
-
#
|
4299
|
-
# fix functions, the values will go on the end
|
4315
|
+
# rn needed for indexing but cn insert
|
4300
4316
|
maxrn = 0
|
4301
4317
|
for cn, rowdict in reversed(columns.items()):
|
4302
4318
|
for rn, v in rowdict.items():
|
4303
|
-
if rn
|
4304
|
-
self.fix_data_len(rn
|
4319
|
+
if rn >= len(self.data):
|
4320
|
+
self.fix_data_len(rn, cn - 1)
|
4305
4321
|
if rn > maxrn:
|
4306
4322
|
maxrn = rn
|
4307
4323
|
self.data[rn].insert(cn, v)
|
@@ -4314,7 +4330,7 @@ class MainTable(tk.Canvas):
|
|
4314
4330
|
(default_row_height for i in range(len(self.row_positions) - 1, maxrn + 1)),
|
4315
4331
|
)
|
4316
4332
|
)
|
4317
|
-
if isinstance(self._headers, list):
|
4333
|
+
if isinstance(self._headers, list) and header:
|
4318
4334
|
self._headers = insert_items(self._headers, header, self.CH.fix_header)
|
4319
4335
|
if push_ops:
|
4320
4336
|
self.adjust_options_post_add_columns(
|
@@ -4431,6 +4447,7 @@ class MainTable(tk.Canvas):
|
|
4431
4447
|
)
|
4432
4448
|
)
|
4433
4449
|
maxcn = 0
|
4450
|
+
# rn needed for insert but cn indexing
|
4434
4451
|
for rn, row in reversed(rows.items()):
|
4435
4452
|
cn = len(row) - 1
|
4436
4453
|
if rn > len(self.data):
|
@@ -4438,7 +4455,7 @@ class MainTable(tk.Canvas):
|
|
4438
4455
|
self.data.insert(rn, row)
|
4439
4456
|
if cn > maxcn:
|
4440
4457
|
maxcn = cn
|
4441
|
-
if isinstance(self._row_index, list):
|
4458
|
+
if isinstance(self._row_index, list) and index:
|
4442
4459
|
self._row_index = insert_items(self._row_index, index, self.RI.fix_index)
|
4443
4460
|
# if not hiding columns then we can extend col positions if necessary
|
4444
4461
|
if add_col_positions and self.all_columns_displayed and maxcn + 1 > len(self.col_positions) - 1:
|
@@ -4540,16 +4557,16 @@ class MainTable(tk.Canvas):
|
|
4540
4557
|
datacn: column[0]
|
4541
4558
|
for datacn, column in zip(reversed(range(data_ins_col, data_ins_col + numcols)), reversed(columns))
|
4542
4559
|
}
|
4543
|
-
|
4560
|
+
else:
|
4544
4561
|
header_data = {
|
4545
4562
|
datacn: self.CH.get_value_for_empty_cell(datacn, c_ops=False)
|
4546
4563
|
for datacn in reversed(range(data_ins_col, data_ins_col + numcols))
|
4547
4564
|
}
|
4548
4565
|
if columns is None:
|
4566
|
+
rowrange = len(self.data) if self.data else 1
|
4549
4567
|
columns = {
|
4550
4568
|
datacn: {
|
4551
|
-
datarn: self.get_value_for_empty_cell(datarn, datacn, c_ops=False)
|
4552
|
-
for datarn in range(len(self.data))
|
4569
|
+
datarn: self.get_value_for_empty_cell(datarn, datacn, c_ops=False) for datarn in range(rowrange)
|
4553
4570
|
}
|
4554
4571
|
for datacn in reversed(range(data_ins_col, data_ins_col + numcols))
|
4555
4572
|
}
|
@@ -4591,7 +4608,7 @@ class MainTable(tk.Canvas):
|
|
4591
4608
|
datarn: v[0]
|
4592
4609
|
for datarn, v in zip(reversed(range(data_ins_row, data_ins_row + numrows)), reversed(rows))
|
4593
4610
|
}
|
4594
|
-
|
4611
|
+
else:
|
4595
4612
|
index_data = {
|
4596
4613
|
datarn: self.RI.get_value_for_empty_cell(datarn, r_ops=False)
|
4597
4614
|
for datarn in reversed(range(data_ins_row, data_ins_row + numrows))
|
@@ -4599,8 +4616,9 @@ class MainTable(tk.Canvas):
|
|
4599
4616
|
if rows is None:
|
4600
4617
|
if total_data_cols is None:
|
4601
4618
|
total_data_cols = self.total_data_cols()
|
4619
|
+
colrange = total_data_cols if total_data_cols else 1
|
4602
4620
|
rows = {
|
4603
|
-
datarn: [self.get_value_for_empty_cell(datarn, c, c_ops=False) for c in range(
|
4621
|
+
datarn: [self.get_value_for_empty_cell(datarn, c, c_ops=False) for c in range(colrange)]
|
4604
4622
|
for datarn in reversed(range(data_ins_row, data_ins_row + numrows))
|
4605
4623
|
}
|
4606
4624
|
else:
|
@@ -4971,7 +4989,7 @@ class MainTable(tk.Canvas):
|
|
4971
4989
|
total_data_cols = at_least_cols
|
4972
4990
|
total_data_cols = max(total_data_cols, len(self.col_positions) - 1)
|
4973
4991
|
if not isinstance(self._headers, int) and include_header and total_data_cols > len(self._headers):
|
4974
|
-
self.CH.fix_header(total_data_cols)
|
4992
|
+
self.CH.fix_header(total_data_cols - 1)
|
4975
4993
|
for rn, r in enumerate(self.data):
|
4976
4994
|
if total_data_cols > (lnr := len(r)):
|
4977
4995
|
r += self.get_empty_row_seq(rn, end=total_data_cols, start=lnr)
|
@@ -5281,7 +5299,7 @@ class MainTable(tk.Canvas):
|
|
5281
5299
|
for i, w in enumerate(widths):
|
5282
5300
|
if i not in diffs:
|
5283
5301
|
widths[i] -= change
|
5284
|
-
self.
|
5302
|
+
self.col_positions = list(accumulate(chain([0], widths)))
|
5285
5303
|
if self.PAR.ops.auto_resize_rows and self.allow_auto_resize_rows and row_pos_exists:
|
5286
5304
|
max_h = can_height - self.PAR.ops.empty_vertical
|
5287
5305
|
if self.PAR.ops.auto_resize_rows < self.min_row_height:
|
@@ -5306,17 +5324,18 @@ class MainTable(tk.Canvas):
|
|
5306
5324
|
if i not in diffs:
|
5307
5325
|
heights[i] -= change
|
5308
5326
|
self.row_positions = list(accumulate(chain([0], heights)))
|
5309
|
-
if
|
5310
|
-
self.PAR.
|
5311
|
-
|
5312
|
-
|
5313
|
-
|
5314
|
-
|
5315
|
-
|
5316
|
-
|
5317
|
-
|
5318
|
-
|
5319
|
-
|
5327
|
+
if self.PAR.ops.auto_resize_row_index is not True:
|
5328
|
+
if can_width >= self.col_positions[-1] + self.PAR.ops.empty_horizontal and self.PAR.xscroll_showing:
|
5329
|
+
self.PAR.xscroll.grid_forget()
|
5330
|
+
self.PAR.xscroll_showing = False
|
5331
|
+
elif (
|
5332
|
+
can_width < self.col_positions[-1] + self.PAR.ops.empty_horizontal
|
5333
|
+
and not self.PAR.xscroll_showing
|
5334
|
+
and not self.PAR.xscroll_disabled
|
5335
|
+
and can_height > 40
|
5336
|
+
):
|
5337
|
+
self.PAR.xscroll.grid(row=2, column=0, columnspan=2, sticky="nswe")
|
5338
|
+
self.PAR.xscroll_showing = True
|
5320
5339
|
if can_height >= self.row_positions[-1] + self.PAR.ops.empty_vertical and self.PAR.yscroll_showing:
|
5321
5340
|
self.PAR.yscroll.grid_forget()
|
5322
5341
|
self.PAR.yscroll_showing = False
|
@@ -5354,7 +5373,7 @@ class MainTable(tk.Canvas):
|
|
5354
5373
|
start_col = bisect_left(self.col_positions, scrollpos_left)
|
5355
5374
|
end_col = bisect_right(self.col_positions, scrollpos_right)
|
5356
5375
|
changed_w = False
|
5357
|
-
if redraw_row_index and self.show_index:
|
5376
|
+
if self.PAR.ops.auto_resize_row_index and redraw_row_index and self.show_index:
|
5358
5377
|
changed_w = self.RI.auto_set_index_width(
|
5359
5378
|
end_row=end_row - 1,
|
5360
5379
|
only_rows=[self.datarn(r) for r in range(start_row if not start_row else start_row - 1, end_row - 1)],
|
tksheet/row_index.py
CHANGED
@@ -173,14 +173,14 @@ class RowIndex(tk.Canvas):
|
|
173
173
|
self.MT.row_positions = [0]
|
174
174
|
self.MT.saved_row_heights = {}
|
175
175
|
|
176
|
-
def set_width(self, new_width: int, set_TL: bool = False) -> None:
|
176
|
+
def set_width(self, new_width: int, set_TL: bool = False, recreate_selection_boxes: bool = True) -> None:
|
177
177
|
self.current_width = new_width
|
178
178
|
try:
|
179
179
|
self.config(width=new_width)
|
180
180
|
except Exception:
|
181
181
|
return
|
182
182
|
if set_TL:
|
183
|
-
self.TL.set_dimensions(new_w=new_width)
|
183
|
+
self.TL.set_dimensions(new_w=new_width, recreate_selection_boxes=recreate_selection_boxes)
|
184
184
|
|
185
185
|
def rc(self, event: object) -> None:
|
186
186
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
@@ -1192,23 +1192,22 @@ class RowIndex(tk.Canvas):
|
|
1192
1192
|
self.MT.recreate_all_selection_boxes()
|
1193
1193
|
|
1194
1194
|
def auto_set_index_width(self, end_row: int, only_rows: list) -> bool:
|
1195
|
-
if self.
|
1196
|
-
if
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
return True
|
1195
|
+
if not isinstance(self.MT._row_index, int) and not self.MT._row_index:
|
1196
|
+
if self.default_index == "letters":
|
1197
|
+
new_w = self.MT.get_txt_w(f"{num2alpha(end_row)}") + 20
|
1198
|
+
elif self.default_index == "numbers":
|
1199
|
+
new_w = self.MT.get_txt_w(f"{end_row}") + 20
|
1200
|
+
elif self.default_index == "both":
|
1201
|
+
new_w = self.MT.get_txt_w(f"{end_row + 1} {num2alpha(end_row)}") + 20
|
1202
|
+
elif self.PAR.ops.auto_resize_row_index is True:
|
1203
|
+
new_w = self.set_width_of_index_to_text(only_rows=only_rows, set_width=False)
|
1204
|
+
else:
|
1205
|
+
new_w = None
|
1206
|
+
if new_w is not None and (sheet_w_x := floor(self.PAR.winfo_width() * 0.7)) < new_w:
|
1207
|
+
new_w = sheet_w_x
|
1208
|
+
if new_w and (self.current_width - new_w > 20 or new_w - self.current_width > 3):
|
1209
|
+
self.set_width(new_w, set_TL=True, recreate_selection_boxes=False)
|
1210
|
+
return True
|
1212
1211
|
return False
|
1213
1212
|
|
1214
1213
|
def redraw_highlight_get_text_fg(self, fr, sr, r, c_2, c_3, selections, datarn):
|
tksheet/sheet.py
CHANGED
@@ -21,7 +21,6 @@ from .functions import (
|
|
21
21
|
dropdown_search_function,
|
22
22
|
event_dict,
|
23
23
|
fix_format_kwargs,
|
24
|
-
new_tk_event,
|
25
24
|
force_bool,
|
26
25
|
get_checkbox_dict,
|
27
26
|
get_checkbox_kwargs,
|
@@ -30,6 +29,7 @@ from .functions import (
|
|
30
29
|
idx_param_to_int,
|
31
30
|
is_iterable,
|
32
31
|
key_to_span,
|
32
|
+
new_tk_event,
|
33
33
|
num2alpha,
|
34
34
|
pickled_event_dict,
|
35
35
|
pop_positions,
|
@@ -130,7 +130,8 @@ class Sheet(tk.Frame):
|
|
130
130
|
show_default_header_for_empty: bool = True,
|
131
131
|
show_default_index_for_empty: bool = True,
|
132
132
|
page_up_down_select_row: bool = True,
|
133
|
-
|
133
|
+
paste_can_expand_x: bool = False,
|
134
|
+
paste_can_expand_y: bool = False,
|
134
135
|
paste_insert_column_limit: int | None = None,
|
135
136
|
paste_insert_row_limit: int | None = None,
|
136
137
|
show_dropdown_borders: bool = False,
|
@@ -265,6 +266,7 @@ class Sheet(tk.Frame):
|
|
265
266
|
header_height: str | int | None = None,
|
266
267
|
row_height: str | int | None = None,
|
267
268
|
row_index_width: int | None = None,
|
269
|
+
expand_sheet_if_paste_too_big: bool | None = None,
|
268
270
|
) -> None:
|
269
271
|
tk.Frame.__init__(
|
270
272
|
self,
|
@@ -283,6 +285,9 @@ class Sheet(tk.Frame):
|
|
283
285
|
default_row_height = row_height
|
284
286
|
if row_index_width is not None:
|
285
287
|
default_row_index_width = row_index_width
|
288
|
+
if expand_sheet_if_paste_too_big is not None:
|
289
|
+
paste_can_expand_x = expand_sheet_if_paste_too_big
|
290
|
+
paste_can_expand_y = expand_sheet_if_paste_too_big
|
286
291
|
if treeview:
|
287
292
|
index_align = "w"
|
288
293
|
auto_resize_row_index = True
|
@@ -4178,10 +4183,13 @@ class Sheet(tk.Frame):
|
|
4178
4183
|
self.MT.max_header_height = float(kwargs["max_header_height"])
|
4179
4184
|
if "max_index_width" in kwargs:
|
4180
4185
|
self.MT.max_index_width = float(kwargs["max_index_width"])
|
4186
|
+
if "expand_sheet_if_paste_too_big" in kwargs:
|
4187
|
+
self.ops.paste_can_expand_x = kwargs["expand_sheet_if_paste_too_big"]
|
4188
|
+
self.ops.paste_can_expand_y = kwargs["expand_sheet_if_paste_too_big"]
|
4181
4189
|
if "font" in kwargs:
|
4182
4190
|
self.MT.set_table_font(kwargs["font"])
|
4183
4191
|
elif "table_font" in kwargs:
|
4184
|
-
self.MT.set_table_font(kwargs["
|
4192
|
+
self.MT.set_table_font(kwargs["table_font"])
|
4185
4193
|
if "header_font" in kwargs:
|
4186
4194
|
self.MT.set_header_font(kwargs["header_font"])
|
4187
4195
|
if "index_font" in kwargs:
|
@@ -4561,7 +4569,7 @@ class Sheet(tk.Frame):
|
|
4561
4569
|
self.tree_set_open(open_ids=open_ids)
|
4562
4570
|
else:
|
4563
4571
|
self.hide_rows(
|
4564
|
-
|
4572
|
+
{self.RI.tree_rns[iid] for iid in self.get_children() if self.RI.tree[iid].parent},
|
4565
4573
|
deselect_all=False,
|
4566
4574
|
data_indexes=True,
|
4567
4575
|
row_heights=False if row_heights is False else True,
|
@@ -4585,46 +4593,76 @@ class Sheet(tk.Frame):
|
|
4585
4593
|
Closes everything else
|
4586
4594
|
"""
|
4587
4595
|
self.hide_rows(
|
4588
|
-
# set(self.MT.displayed_rows),
|
4589
4596
|
set(rn for rn in self.MT.displayed_rows if self.MT._row_index[rn].parent),
|
4590
4597
|
redraw=False,
|
4591
4598
|
deselect_all=False,
|
4592
4599
|
data_indexes=True,
|
4593
4600
|
)
|
4594
|
-
# self.show_rows(
|
4595
|
-
# (self.RI.tree_rns[iid] for iid in self.get_children("")),
|
4596
|
-
# redraw=False,
|
4597
|
-
# deselect_all=True,
|
4598
|
-
# )
|
4599
4601
|
open_ids = set(filter(self.exists, map(str.lower, open_ids)))
|
4600
4602
|
self.RI.tree_open_ids = set()
|
4601
4603
|
if open_ids:
|
4602
|
-
self.
|
4603
|
-
|
4604
|
+
to_open = self._tree_open(open_ids)
|
4605
|
+
self.show_rows(
|
4606
|
+
rows=to_open,
|
4607
|
+
redraw=False,
|
4608
|
+
deselect_all=False,
|
4609
|
+
)
|
4610
|
+
return self.set_refresh_timer(True)
|
4604
4611
|
|
4605
|
-
def
|
4612
|
+
def _tree_open(self, items: set[str]) -> list[int]:
|
4613
|
+
"""
|
4614
|
+
Only meant for internal use
|
4615
|
+
"""
|
4616
|
+
to_open = []
|
4617
|
+
for item in filter(items.__contains__, self.get_children()):
|
4618
|
+
if self.RI.tree[item].children:
|
4619
|
+
self.RI.tree_open_ids.add(item)
|
4620
|
+
to_open.extend(self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True))
|
4621
|
+
return to_open
|
4622
|
+
|
4623
|
+
def tree_open(self, *items, redraw: bool = True) -> Sheet:
|
4606
4624
|
"""
|
4607
4625
|
If used without args all items are opened
|
4608
4626
|
"""
|
4609
4627
|
if items := set(unpack(items)):
|
4610
|
-
|
4611
|
-
self.item(item, open_=True)
|
4628
|
+
to_open = self._tree_open(items)
|
4612
4629
|
else:
|
4630
|
+
to_open = []
|
4613
4631
|
for item in self.get_children():
|
4614
|
-
self.item
|
4615
|
-
|
4632
|
+
if self.RI.tree[item].children:
|
4633
|
+
self.RI.tree_open_ids.add(item)
|
4634
|
+
to_open.extend(self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True))
|
4635
|
+
return self.show_rows(
|
4636
|
+
rows=to_open,
|
4637
|
+
redraw=redraw,
|
4638
|
+
deselect_all=False,
|
4639
|
+
)
|
4616
4640
|
|
4617
|
-
def tree_close(self, *items) -> Sheet:
|
4641
|
+
def tree_close(self, *items, redraw: bool = True) -> Sheet:
|
4618
4642
|
"""
|
4619
4643
|
If used without args all items are closed
|
4620
4644
|
"""
|
4645
|
+
to_close = set()
|
4621
4646
|
if items:
|
4622
4647
|
for item in unpack(items):
|
4623
|
-
self.item
|
4648
|
+
if self.RI.tree[item].children:
|
4649
|
+
self.RI.tree_open_ids.discard(item)
|
4650
|
+
if self.RI.tree_rns[item] in self.MT.displayed_rows:
|
4651
|
+
for did in self.RI.get_iid_descendants(item, check_open=True):
|
4652
|
+
to_close.add(self.RI.tree_rns[did])
|
4624
4653
|
else:
|
4625
4654
|
for item in self.get_children():
|
4626
|
-
self.item
|
4627
|
-
|
4655
|
+
if self.RI.tree[item].children:
|
4656
|
+
self.RI.tree_open_ids.discard(item)
|
4657
|
+
if self.RI.tree_rns[item] in self.MT.displayed_rows:
|
4658
|
+
for did in self.RI.get_iid_descendants(item, check_open=True):
|
4659
|
+
to_close.add(self.RI.tree_rns[did])
|
4660
|
+
return self.hide_rows(
|
4661
|
+
rows=to_close,
|
4662
|
+
redraw=redraw,
|
4663
|
+
deselect_all=False,
|
4664
|
+
data_indexes=True,
|
4665
|
+
)
|
4628
4666
|
|
4629
4667
|
def insert(
|
4630
4668
|
self,
|
tksheet/sheet_options.py
CHANGED
@@ -218,7 +218,8 @@ def new_sheet_options() -> DotDict:
|
|
218
218
|
"default_column_width": 120,
|
219
219
|
"default_row_index_width": 70,
|
220
220
|
"page_up_down_select_row": True,
|
221
|
-
"
|
221
|
+
"paste_can_expand_x": False,
|
222
|
+
"paste_can_expand_y": False,
|
222
223
|
"paste_insert_column_limit": None,
|
223
224
|
"paste_insert_row_limit": None,
|
224
225
|
"arrow_key_down_right_scroll_page": False,
|
tksheet/top_left_rectangle.py
CHANGED
@@ -156,7 +156,7 @@ class TopLeftRectangle(tk.Canvas):
|
|
156
156
|
self.unbind("<Double-Button-1>")
|
157
157
|
self.unbind(rc_binding)
|
158
158
|
|
159
|
-
def set_dimensions(self, new_w=None, new_h=None) -> None:
|
159
|
+
def set_dimensions(self, new_w=None, new_h=None, recreate_selection_boxes: bool = True) -> None:
|
160
160
|
try:
|
161
161
|
if new_h is None:
|
162
162
|
h = self.winfo_height()
|
@@ -182,7 +182,8 @@ class TopLeftRectangle(tk.Canvas):
|
|
182
182
|
h - 7,
|
183
183
|
)
|
184
184
|
self.coords(self.select_all_box, 0, 0, w - 5, h - 5)
|
185
|
-
|
185
|
+
if recreate_selection_boxes:
|
186
|
+
self.MT.recreate_all_selection_boxes()
|
186
187
|
|
187
188
|
def mouse_motion(self, event: object = None) -> None:
|
188
189
|
self.MT.reset_mouse_motion_creations()
|
@@ -0,0 +1,20 @@
|
|
1
|
+
tksheet/__init__.py,sha256=bYFOinsbKFaindyR5hphr10ksW8kUfR4AEe4rJT5Unc,2125
|
2
|
+
tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
|
3
|
+
tksheet/column_headers.py,sha256=cWTHyYaA5nNMfT6WyFJB0lyeNQFRVXZPbX9C-lLH4Yg,100770
|
4
|
+
tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
|
5
|
+
tksheet/functions.py,sha256=rNfDpQRoXZm_Ro-tlF92ox3fi37p71Mio1PGTreM_oc,40835
|
6
|
+
tksheet/main_table.py,sha256=5K9KhqDmN_jtU6g5e-WMB38usM2CXNljc7x-KihQQGc,323238
|
7
|
+
tksheet/other_classes.py,sha256=P3FYUYreLhstATvHCNow8sDQoCsD_02KB6oXcca3ahE,13628
|
8
|
+
tksheet/row_index.py,sha256=jtMXKebCv7Num7IJ793nMcetP6y-1QvHN9vTfUZ6Yn8,107068
|
9
|
+
tksheet/sheet.py,sha256=nP2KeD7muHyakHOjmbAhQ1rMP9UuUxG1l8RvBW--Nqo,266377
|
10
|
+
tksheet/sheet_options.py,sha256=Azo7_-H0e0ssYEoU7Mq_OWy3S-U05rp4_6Q2E2Ffuu8,12262
|
11
|
+
tksheet/text_editor.py,sha256=DGFgukHZ5gruA_hWN1cuhv88z0nR5316xGynx3OioWQ,6548
|
12
|
+
tksheet/themes.py,sha256=IeOgexzqgEM11i8Ie3awIL7nH9DVm65eW4XCcrRK9HE,14480
|
13
|
+
tksheet/top_left_rectangle.py,sha256=JDByauKiEBPoJfLWcZsU26XTqMLVtrGsI0wFLT9Yv2w,8356
|
14
|
+
tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
|
15
|
+
tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
|
16
|
+
tksheet-7.1.24.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
|
17
|
+
tksheet-7.1.24.dist-info/METADATA,sha256=I5SKJOJiVpCPKxfZaWHY-SlzfuNrH6skuDzAKpvR2n8,6146
|
18
|
+
tksheet-7.1.24.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
19
|
+
tksheet-7.1.24.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
|
20
|
+
tksheet-7.1.24.dist-info/RECORD,,
|
tksheet-7.1.22.dist-info/RECORD
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
tksheet/__init__.py,sha256=WycEvqmjym6j4M6uhjfRP1epMXGkfU87U08AeMbavAI,2125
|
2
|
-
tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
|
3
|
-
tksheet/column_headers.py,sha256=cWTHyYaA5nNMfT6WyFJB0lyeNQFRVXZPbX9C-lLH4Yg,100770
|
4
|
-
tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
|
5
|
-
tksheet/functions.py,sha256=rNfDpQRoXZm_Ro-tlF92ox3fi37p71Mio1PGTreM_oc,40835
|
6
|
-
tksheet/main_table.py,sha256=Z9ih53-4t2OoPyIbXczSSPiIt3oCBzR7UQJF9l3dfFg,322148
|
7
|
-
tksheet/other_classes.py,sha256=P3FYUYreLhstATvHCNow8sDQoCsD_02KB6oXcca3ahE,13628
|
8
|
-
tksheet/row_index.py,sha256=6J72VDTufsoPCxhmH4C-ARPcy0Qq5QaXq4erQXPLosE,107058
|
9
|
-
tksheet/sheet.py,sha256=07BGVsrBYV1xviJ7quKnmZA-QwLVJV6CcbAYz23Llp4,264445
|
10
|
-
tksheet/sheet_options.py,sha256=rf1xtaZdGnJYSgR_sFsYlGSEj3bYHpSm15CH2aZETUo,12231
|
11
|
-
tksheet/text_editor.py,sha256=DGFgukHZ5gruA_hWN1cuhv88z0nR5316xGynx3OioWQ,6548
|
12
|
-
tksheet/themes.py,sha256=IeOgexzqgEM11i8Ie3awIL7nH9DVm65eW4XCcrRK9HE,14480
|
13
|
-
tksheet/top_left_rectangle.py,sha256=-2u9GfOvcqhkKwHEtbqdFvXCY3RbvL5k2Sh9l3r_k04,8275
|
14
|
-
tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
|
15
|
-
tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
|
16
|
-
tksheet-7.1.22.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
|
17
|
-
tksheet-7.1.22.dist-info/METADATA,sha256=fPSQKrzQyNTD_TImpXq5a2Baaj0VOpchtk9nUGavYGw,6146
|
18
|
-
tksheet-7.1.22.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
19
|
-
tksheet-7.1.22.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
|
20
|
-
tksheet-7.1.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|