tksheet 7.1.7__py3-none-any.whl → 7.1.9__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 +3 -5
- tksheet/column_headers.py +12 -4
- tksheet/functions.py +8 -5
- tksheet/main_table.py +131 -229
- tksheet/other_classes.py +2 -5
- tksheet/row_index.py +12 -4
- tksheet/sheet.py +139 -61
- tksheet/vars.py +10 -0
- {tksheet-7.1.7.dist-info → tksheet-7.1.9.dist-info}/METADATA +1 -1
- tksheet-7.1.9.dist-info/RECORD +20 -0
- tksheet/listbox.py +0 -19
- tksheet-7.1.7.dist-info/RECORD +0 -21
- {tksheet-7.1.7.dist-info → tksheet-7.1.9.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.1.7.dist-info → tksheet-7.1.9.dist-info}/WHEEL +0 -0
- {tksheet-7.1.7.dist-info → tksheet-7.1.9.dist-info}/top_level.txt +0 -0
tksheet/main_table.py
CHANGED
@@ -26,7 +26,6 @@ from itertools import (
|
|
26
26
|
chain,
|
27
27
|
cycle,
|
28
28
|
islice,
|
29
|
-
product,
|
30
29
|
repeat,
|
31
30
|
)
|
32
31
|
from math import (
|
@@ -56,7 +55,6 @@ from .functions import (
|
|
56
55
|
ev_stack_dict,
|
57
56
|
event_dict,
|
58
57
|
gen_formatted,
|
59
|
-
rounded_box_coords,
|
60
58
|
get_new_indexes,
|
61
59
|
get_seq_without_gaps_at_index,
|
62
60
|
index_exists,
|
@@ -67,10 +65,11 @@ from .functions import (
|
|
67
65
|
len_to_idx,
|
68
66
|
mod_event_val,
|
69
67
|
mod_span,
|
68
|
+
mod_span_widget,
|
70
69
|
move_elements_by_mapping,
|
71
70
|
pickle_obj,
|
71
|
+
rounded_box_coords,
|
72
72
|
span_idxs_post_move,
|
73
|
-
mod_span_widget,
|
74
73
|
try_binding,
|
75
74
|
unpickle_obj,
|
76
75
|
)
|
@@ -82,6 +81,7 @@ from .other_classes import (
|
|
82
81
|
DropdownStorage,
|
83
82
|
EventDataDict,
|
84
83
|
FontTuple,
|
84
|
+
Loc,
|
85
85
|
Selected,
|
86
86
|
SelectionBox,
|
87
87
|
TextEditorStorage,
|
@@ -94,6 +94,7 @@ from .vars import (
|
|
94
94
|
ctrl_key,
|
95
95
|
rc_binding,
|
96
96
|
symbols_set,
|
97
|
+
text_editor_to_unbind,
|
97
98
|
val_modifying_options,
|
98
99
|
)
|
99
100
|
|
@@ -675,7 +676,7 @@ class MainTable(tk.Canvas):
|
|
675
676
|
if lastbox_numrows > new_data_numrows and not lastbox_numrows % new_data_numrows:
|
676
677
|
nd = []
|
677
678
|
for _ in range(int(lastbox_numrows / new_data_numrows)):
|
678
|
-
nd.extend(
|
679
|
+
nd.extend(r.copy() for r in data)
|
679
680
|
data.extend(nd)
|
680
681
|
new_data_numrows *= int(lastbox_numrows / new_data_numrows)
|
681
682
|
|
@@ -971,14 +972,14 @@ class MainTable(tk.Canvas):
|
|
971
972
|
run_binding=True,
|
972
973
|
)
|
973
974
|
if move_data:
|
974
|
-
self.data
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
975
|
+
self.data = list(
|
976
|
+
map(
|
977
|
+
move_elements_by_mapping,
|
978
|
+
self.data,
|
979
|
+
repeat(data_new_idxs),
|
980
|
+
repeat(data_old_idxs),
|
981
|
+
),
|
982
|
+
)
|
982
983
|
maxidx = len_to_idx(totalcols)
|
983
984
|
self.CH.fix_header(maxidx)
|
984
985
|
if isinstance(self._headers, list) and self._headers:
|
@@ -1129,7 +1130,11 @@ class MainTable(tk.Canvas):
|
|
1129
1130
|
)
|
1130
1131
|
else:
|
1131
1132
|
disp_new_idxs = {}
|
1132
|
-
|
1133
|
+
self.fix_data_len(move_to)
|
1134
|
+
totalrows = max(
|
1135
|
+
self.total_data_rows(),
|
1136
|
+
len(self.row_positions) - 1,
|
1137
|
+
)
|
1133
1138
|
if self.all_rows_displayed or data_indexes:
|
1134
1139
|
data_new_idxs = get_new_indexes(seqlen=totalrows, move_to=move_to, to_move=to_move)
|
1135
1140
|
elif not self.all_rows_displayed and not data_indexes:
|
@@ -1156,7 +1161,12 @@ class MainTable(tk.Canvas):
|
|
1156
1161
|
) -> tuple[dict[int, int], dict[int, int], EventDataDict]:
|
1157
1162
|
self.saved_row_heights = {}
|
1158
1163
|
if not isinstance(totalrows, int):
|
1159
|
-
totalrows =
|
1164
|
+
totalrows = max(
|
1165
|
+
self.total_data_rows(),
|
1166
|
+
len(self.row_positions) - 1,
|
1167
|
+
max(data_new_idxs.values(), default=0),
|
1168
|
+
)
|
1169
|
+
totalrows = self.fix_data_len(totalrows)
|
1160
1170
|
if event_data is None:
|
1161
1171
|
event_data = event_dict(
|
1162
1172
|
name="move_rows",
|
@@ -1195,7 +1205,7 @@ class MainTable(tk.Canvas):
|
|
1195
1205
|
run_binding=True,
|
1196
1206
|
)
|
1197
1207
|
if move_data:
|
1198
|
-
self.data
|
1208
|
+
self.data = move_elements_by_mapping(
|
1199
1209
|
self.data,
|
1200
1210
|
data_new_idxs,
|
1201
1211
|
data_old_idxs,
|
@@ -1443,9 +1453,7 @@ class MainTable(tk.Canvas):
|
|
1443
1453
|
saved_cells = True
|
1444
1454
|
|
1445
1455
|
if modification["moved"]["columns"]:
|
1446
|
-
totalcols = self.equalize_data_row_lengths()
|
1447
|
-
if totalcols < (mx_k := max(modification["moved"]["columns"]["data"].values())):
|
1448
|
-
totalcols = mx_k
|
1456
|
+
totalcols = max(self.equalize_data_row_lengths(), max(modification["moved"]["columns"]["data"].values()))
|
1449
1457
|
data_new_idxs, disp_new_idxs, event_data = self.move_columns_adjust_options_dict(
|
1450
1458
|
data_new_idxs=dict(
|
1451
1459
|
zip(
|
@@ -1470,9 +1478,7 @@ class MainTable(tk.Canvas):
|
|
1470
1478
|
self.restore_options_named_spans(modification)
|
1471
1479
|
|
1472
1480
|
if modification["moved"]["rows"]:
|
1473
|
-
totalrows = self.total_data_rows()
|
1474
|
-
if totalrows < (mx_k := max(modification["moved"]["rows"]["data"].values())):
|
1475
|
-
totalrows = mx_k
|
1481
|
+
totalrows = max(self.total_data_rows(), max(modification["moved"]["rows"]["data"].values()))
|
1476
1482
|
data_new_idxs, disp_new_idxs, event_data = self.move_rows_adjust_options_dict(
|
1477
1483
|
data_new_idxs=dict(
|
1478
1484
|
zip(
|
@@ -2744,8 +2750,7 @@ class MainTable(tk.Canvas):
|
|
2744
2750
|
|
2745
2751
|
def mouse_motion(self, event: object):
|
2746
2752
|
self.reset_mouse_motion_creations()
|
2747
|
-
|
2748
|
-
self.extra_motion_func(event)
|
2753
|
+
try_binding(self.extra_motion_func, event)
|
2749
2754
|
|
2750
2755
|
def not_currently_resizing(self) -> bool:
|
2751
2756
|
return all(v is None for v in (self.RI.rsz_h, self.RI.rsz_w, self.CH.rsz_h, self.CH.rsz_w))
|
@@ -2758,12 +2763,15 @@ class MainTable(tk.Canvas):
|
|
2758
2763
|
r = self.identify_row(y=event.y)
|
2759
2764
|
c = self.identify_col(x=event.x)
|
2760
2765
|
if r < len(self.row_positions) - 1 and c < len(self.col_positions) - 1:
|
2761
|
-
if self.col_selected(c)
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2766
|
+
if self.col_selected(c):
|
2767
|
+
if self.rc_popup_menus_enabled:
|
2768
|
+
popup_menu = self.CH.ch_rc_popup_menu
|
2769
|
+
elif self.row_selected(r):
|
2770
|
+
if self.rc_popup_menus_enabled:
|
2771
|
+
popup_menu = self.RI.ri_rc_popup_menu
|
2772
|
+
elif self.cell_selected(r, c):
|
2773
|
+
if self.rc_popup_menus_enabled:
|
2774
|
+
popup_menu = self.rc_popup_menu
|
2767
2775
|
else:
|
2768
2776
|
if self.rc_select_enabled:
|
2769
2777
|
if self.single_selection_enabled:
|
@@ -2773,9 +2781,9 @@ class MainTable(tk.Canvas):
|
|
2773
2781
|
if self.rc_popup_menus_enabled:
|
2774
2782
|
popup_menu = self.rc_popup_menu
|
2775
2783
|
else:
|
2784
|
+
self.deselect("all")
|
2776
2785
|
popup_menu = self.empty_rc_popup_menu
|
2777
|
-
|
2778
|
-
self.extra_rc_func(event)
|
2786
|
+
try_binding(self.extra_rc_func, event)
|
2779
2787
|
if popup_menu is not None:
|
2780
2788
|
popup_menu.tk_popup(event.x_root, event.y_root)
|
2781
2789
|
|
@@ -2799,8 +2807,7 @@ class MainTable(tk.Canvas):
|
|
2799
2807
|
if r < len(self.row_positions) - 1 and c < len(self.col_positions) - 1:
|
2800
2808
|
self.toggle_select_cell(r, c, redraw=True)
|
2801
2809
|
self.b1_pressed_loc = (r, c)
|
2802
|
-
|
2803
|
-
self.extra_b1_press_func(event)
|
2810
|
+
try_binding(self.extra_b1_press_func, event)
|
2804
2811
|
|
2805
2812
|
def create_resize_line(self, x1, y1, x2, y2, width, fill, tag):
|
2806
2813
|
if self.hidd_resize_lines:
|
@@ -2968,8 +2975,7 @@ class MainTable(tk.Canvas):
|
|
2968
2975
|
need_redraw = True
|
2969
2976
|
if need_redraw:
|
2970
2977
|
self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True, redraw_table=True)
|
2971
|
-
|
2972
|
-
self.extra_b1_motion_func(event)
|
2978
|
+
try_binding(self.extra_b1_motion_func, event)
|
2973
2979
|
|
2974
2980
|
def ctrl_b1_motion(self, event: object):
|
2975
2981
|
if self.ctrl_select_enabled and self.drag_selection_enabled and self.not_currently_resizing():
|
@@ -3081,8 +3087,7 @@ class MainTable(tk.Canvas):
|
|
3081
3087
|
self.mouseclick_outside_editor_or_dropdown_all_canvases()
|
3082
3088
|
self.b1_pressed_loc = None
|
3083
3089
|
self.closed_dropdown = None
|
3084
|
-
|
3085
|
-
self.extra_b1_release_func(event)
|
3090
|
+
try_binding(self.extra_b1_release_func, event)
|
3086
3091
|
|
3087
3092
|
def double_b1(self, event=None):
|
3088
3093
|
self.mouseclick_outside_editor_or_dropdown_all_canvases()
|
@@ -3106,8 +3111,7 @@ class MainTable(tk.Canvas):
|
|
3106
3111
|
self.toggle_select_cell(r, c, redraw=True)
|
3107
3112
|
if self.edit_cell_enabled:
|
3108
3113
|
self.open_cell(event)
|
3109
|
-
|
3110
|
-
self.extra_double_b1_func(event)
|
3114
|
+
try_binding(self.extra_double_b1_func, event)
|
3111
3115
|
|
3112
3116
|
def identify_row(self, event=None, y=None, allow_end=True):
|
3113
3117
|
if event is None:
|
@@ -3213,39 +3217,30 @@ class MainTable(tk.Canvas):
|
|
3213
3217
|
# continue
|
3214
3218
|
|
3215
3219
|
def set_xviews(self, *args, move_synced: bool = True, redraw: bool = True) -> None:
|
3220
|
+
self.main_table_redraw_grid_and_text(setting_views=True)
|
3221
|
+
self.update_idletasks()
|
3216
3222
|
self.xview(*args)
|
3217
3223
|
if self.show_header:
|
3218
3224
|
self.CH.xview(*args)
|
3219
3225
|
if move_synced:
|
3220
3226
|
self.x_move_synced_scrolls(*args)
|
3221
3227
|
self.fix_views()
|
3222
|
-
|
3223
|
-
self.main_table_redraw_grid_and_text(redraw_header=True if self.show_header else False)
|
3228
|
+
self.PAR.set_refresh_timer(redraw)
|
3224
3229
|
|
3225
3230
|
def set_yviews(self, *args, move_synced: bool = True, redraw: bool = True) -> None:
|
3231
|
+
self.main_table_redraw_grid_and_text(setting_views=True)
|
3232
|
+
self.update_idletasks()
|
3226
3233
|
self.yview(*args)
|
3227
3234
|
if self.show_index:
|
3228
3235
|
self.RI.yview(*args)
|
3229
3236
|
if move_synced:
|
3230
3237
|
self.y_move_synced_scrolls(*args)
|
3231
3238
|
self.fix_views()
|
3232
|
-
|
3233
|
-
self.main_table_redraw_grid_and_text(redraw_row_index=True if self.show_index else False)
|
3239
|
+
self.PAR.set_refresh_timer(redraw)
|
3234
3240
|
|
3235
3241
|
def set_view(self, x_args: list[str, float], y_args: list[str, float]) -> None:
|
3236
|
-
self.
|
3237
|
-
|
3238
|
-
self.CH.xview(*x_args)
|
3239
|
-
self.yview(*y_args)
|
3240
|
-
if self.show_index:
|
3241
|
-
self.RI.yview(*y_args)
|
3242
|
-
self.x_move_synced_scrolls(*x_args)
|
3243
|
-
self.y_move_synced_scrolls(*y_args)
|
3244
|
-
self.fix_views()
|
3245
|
-
self.main_table_redraw_grid_and_text(
|
3246
|
-
redraw_row_index=True if self.show_index else False,
|
3247
|
-
redraw_header=True if self.show_header else False,
|
3248
|
-
)
|
3242
|
+
self.set_xviews(*x_args)
|
3243
|
+
self.set_yviews(*y_args)
|
3249
3244
|
|
3250
3245
|
def mousewheel(self, event: object) -> None:
|
3251
3246
|
if event.delta < 0 or event.num == 5:
|
@@ -3337,7 +3332,9 @@ class MainTable(tk.Canvas):
|
|
3337
3332
|
else (
|
3338
3333
|
default_row_height
|
3339
3334
|
if h == old_default_row_height
|
3340
|
-
else self.min_row_height
|
3335
|
+
else self.min_row_height
|
3336
|
+
if h < self.min_row_height
|
3337
|
+
else h
|
3341
3338
|
)
|
3342
3339
|
)
|
3343
3340
|
for h in self.gen_row_heights()
|
@@ -4282,7 +4279,7 @@ class MainTable(tk.Canvas):
|
|
4282
4279
|
return event_data
|
4283
4280
|
|
4284
4281
|
def rc_add_columns(self, event: object = None):
|
4285
|
-
rowlen = self.equalize_data_row_lengths(
|
4282
|
+
rowlen = self.equalize_data_row_lengths()
|
4286
4283
|
selcols = sorted(self.get_selected_cols())
|
4287
4284
|
if (
|
4288
4285
|
selcols
|
@@ -4868,24 +4865,15 @@ class MainTable(tk.Canvas):
|
|
4868
4865
|
return self._row_index
|
4869
4866
|
|
4870
4867
|
def total_data_cols(self, include_header: bool = True) -> int:
|
4871
|
-
h_total = 0
|
4872
|
-
|
4873
|
-
if include_header:
|
4874
|
-
if isinstance(self._headers, (list, tuple)):
|
4875
|
-
h_total = len(self._headers)
|
4876
|
-
# map() for some reason is 15% faster than max(key=len)
|
4877
|
-
# using python 3.11 windows 11
|
4868
|
+
h_total = len(self._headers) if include_header and isinstance(self._headers, (list, tuple)) else 0
|
4869
|
+
# map() for some reason is 15% faster than max(key=len) using python 3.11 windows 11
|
4878
4870
|
d_total = max(map(len, self.data), default=0)
|
4879
|
-
return h_total
|
4871
|
+
return max(h_total, d_total)
|
4880
4872
|
|
4881
4873
|
def total_data_rows(self, include_index: bool = True) -> int:
|
4882
|
-
i_total = 0
|
4883
|
-
d_total = 0
|
4884
|
-
if include_index:
|
4885
|
-
if isinstance(self._row_index, (list, tuple)):
|
4886
|
-
i_total = len(self._row_index)
|
4874
|
+
i_total = len(self._row_index) if include_index and isinstance(self._row_index, (list, tuple)) else 0
|
4887
4875
|
d_total = len(self.data)
|
4888
|
-
return i_total
|
4876
|
+
return max(i_total, d_total)
|
4889
4877
|
|
4890
4878
|
def data_dimensions(self, total_rows: int | None = None, total_columns: int | None = None):
|
4891
4879
|
if total_rows is None and total_columns is None:
|
@@ -4893,7 +4881,7 @@ class MainTable(tk.Canvas):
|
|
4893
4881
|
if total_rows is not None:
|
4894
4882
|
if len(self.data) < total_rows:
|
4895
4883
|
ncols = self.total_data_cols() if total_columns is None else total_columns
|
4896
|
-
self.data.extend(
|
4884
|
+
self.data.extend(self.get_empty_row_seq(r, ncols) for r in range(total_rows - len(self.data)))
|
4897
4885
|
else:
|
4898
4886
|
self.data[total_rows:] = []
|
4899
4887
|
if total_columns is not None:
|
@@ -4905,7 +4893,7 @@ class MainTable(tk.Canvas):
|
|
4905
4893
|
|
4906
4894
|
def equalize_data_row_lengths(
|
4907
4895
|
self,
|
4908
|
-
include_header: bool =
|
4896
|
+
include_header: bool = True,
|
4909
4897
|
total_data_cols: int | None = None,
|
4910
4898
|
at_least_cols: int | None = None,
|
4911
4899
|
) -> int:
|
@@ -4913,6 +4901,7 @@ class MainTable(tk.Canvas):
|
|
4913
4901
|
total_data_cols = self.total_data_cols(include_header=include_header)
|
4914
4902
|
if isinstance(at_least_cols, int) and at_least_cols > total_data_cols:
|
4915
4903
|
total_data_cols = at_least_cols
|
4904
|
+
total_data_cols = max(total_data_cols, len(self.col_positions) - 1)
|
4916
4905
|
if include_header and total_data_cols > len(self._headers):
|
4917
4906
|
self.CH.fix_header(total_data_cols)
|
4918
4907
|
for rn, r in enumerate(self.data):
|
@@ -5193,6 +5182,7 @@ class MainTable(tk.Canvas):
|
|
5193
5182
|
redraw_header: bool = False,
|
5194
5183
|
redraw_row_index: bool = False,
|
5195
5184
|
redraw_table: bool = True,
|
5185
|
+
setting_views: bool = False,
|
5196
5186
|
) -> bool:
|
5197
5187
|
try:
|
5198
5188
|
can_width = self.winfo_width()
|
@@ -5286,6 +5276,8 @@ class MainTable(tk.Canvas):
|
|
5286
5276
|
if scrollregion != self.scrollregion:
|
5287
5277
|
self.configure(scrollregion=scrollregion)
|
5288
5278
|
self.scrollregion = scrollregion
|
5279
|
+
if setting_views:
|
5280
|
+
return False
|
5289
5281
|
scrollpos_bot = self.canvasy(can_height)
|
5290
5282
|
end_row = bisect_right(self.row_positions, scrollpos_bot)
|
5291
5283
|
if not scrollpos_bot >= self.row_positions[-1]:
|
@@ -5765,8 +5757,8 @@ class MainTable(tk.Canvas):
|
|
5765
5757
|
fill, outline = self.get_selected_box_bg_fg(type_=type_)
|
5766
5758
|
x1 = self.col_positions[c] + 1
|
5767
5759
|
y1 = self.row_positions[r] + 1
|
5768
|
-
x2 = self.col_positions[c + 1] if index_exists(self.col_positions, c + 1) else self.col_positions[c]
|
5769
|
-
y2 = self.row_positions[r + 1] if index_exists(self.row_positions, r + 1) else self.row_positions[r]
|
5760
|
+
x2 = self.col_positions[c + 1] if index_exists(self.col_positions, c + 1) else self.col_positions[c] + 1
|
5761
|
+
y2 = self.row_positions[r + 1] if index_exists(self.row_positions, r + 1) else self.row_positions[r] + 1
|
5770
5762
|
self.hide_selected()
|
5771
5763
|
if self.PAR.ops.show_selected_cells_border:
|
5772
5764
|
fill = ""
|
@@ -5809,12 +5801,16 @@ class MainTable(tk.Canvas):
|
|
5809
5801
|
width: int,
|
5810
5802
|
iid: None | int = None,
|
5811
5803
|
) -> int:
|
5804
|
+
if not self.PAR.ops.rounded_boxes or not x2 - x1 or not y2 - y1:
|
5805
|
+
radius = 0
|
5806
|
+
else:
|
5807
|
+
radius = 8
|
5812
5808
|
coords = rounded_box_coords(
|
5813
5809
|
x1,
|
5814
5810
|
y1,
|
5815
5811
|
x2,
|
5816
5812
|
y2,
|
5817
|
-
radius=
|
5813
|
+
radius=radius,
|
5818
5814
|
)
|
5819
5815
|
if isinstance(iid, int):
|
5820
5816
|
self.itemconfig(iid, fill=fill, outline=outline, state=state, tags=tags, width=width)
|
@@ -5844,7 +5840,7 @@ class MainTable(tk.Canvas):
|
|
5844
5840
|
self.itemconfig(item, state="hidden")
|
5845
5841
|
|
5846
5842
|
def hide_selection_box(self, item: int | None, set_current: bool = True) -> bool:
|
5847
|
-
if item is None:
|
5843
|
+
if item is None or item is True:
|
5848
5844
|
return
|
5849
5845
|
box = self.selection_boxes.pop(item)
|
5850
5846
|
self.hide_box(box.fill_iid)
|
@@ -6048,7 +6044,7 @@ class MainTable(tk.Canvas):
|
|
6048
6044
|
tags="cells" if type_ == "rows" else type_,
|
6049
6045
|
iid=self.selection_boxes[fill_iid].header,
|
6050
6046
|
)
|
6051
|
-
if
|
6047
|
+
if bd_iid := self.selection_boxes[fill_iid].bd_iid:
|
6052
6048
|
if self.PAR.ops.show_selected_cells_border:
|
6053
6049
|
self.display_box(
|
6054
6050
|
x1,
|
@@ -6147,168 +6143,62 @@ class MainTable(tk.Canvas):
|
|
6147
6143
|
def get_selected_rows(
|
6148
6144
|
self,
|
6149
6145
|
get_cells: bool = False,
|
6150
|
-
within_range: tuple | None = None,
|
6151
6146
|
get_cells_as_rows: bool = False,
|
6152
6147
|
) -> set[int] | set[tuple[int, int]]:
|
6153
|
-
s = set()
|
6154
|
-
if within_range is not None:
|
6155
|
-
within_r1 = within_range[0]
|
6156
|
-
within_r2 = within_range[1]
|
6157
6148
|
if get_cells:
|
6158
|
-
|
6159
|
-
|
6160
|
-
|
6161
|
-
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6165
|
-
|
6166
|
-
r1, c1, r2, c2 = box.coords
|
6167
|
-
if r1 >= within_r1 or r2 <= within_r2:
|
6168
|
-
s.update(
|
6169
|
-
set(
|
6170
|
-
product(
|
6171
|
-
range(r1 if r1 > within_r1 else within_r1, r2 if r2 < within_r2 else within_r2),
|
6172
|
-
range(0, len(self.col_positions) - 1),
|
6173
|
-
)
|
6174
|
-
)
|
6175
|
-
)
|
6176
|
-
if get_cells_as_rows:
|
6177
|
-
s.update(
|
6178
|
-
self.get_selected_cells(
|
6179
|
-
within_range=(
|
6180
|
-
within_r1,
|
6181
|
-
0,
|
6182
|
-
within_r2,
|
6183
|
-
len(self.col_positions) - 1,
|
6184
|
-
)
|
6185
|
-
)
|
6186
|
-
)
|
6149
|
+
s = {
|
6150
|
+
(r, c)
|
6151
|
+
for item, box in self.get_selection_items(cells=False, columns=False)
|
6152
|
+
for r in range(box.coords.from_r, box.coords.upto_r)
|
6153
|
+
for c in range(0, len(self.col_positions) - 1)
|
6154
|
+
}
|
6155
|
+
if get_cells_as_rows:
|
6156
|
+
return s | self.get_selected_cells()
|
6187
6157
|
else:
|
6188
|
-
|
6189
|
-
|
6190
|
-
|
6191
|
-
|
6192
|
-
|
6193
|
-
|
6194
|
-
|
6195
|
-
for item, box in self.get_selection_items(cells=False, columns=False):
|
6196
|
-
r1, c1, r2, c2 = box.coords
|
6197
|
-
if r1 >= within_r1 or r2 <= within_r2:
|
6198
|
-
s.update(set(range(r1 if r1 > within_r1 else within_r1, r2 if r2 < within_r2 else within_r2)))
|
6199
|
-
if get_cells_as_rows:
|
6200
|
-
s.update(
|
6201
|
-
set(
|
6202
|
-
tup[0]
|
6203
|
-
for tup in self.get_selected_cells(
|
6204
|
-
within_range=(
|
6205
|
-
within_r1,
|
6206
|
-
0,
|
6207
|
-
within_r2,
|
6208
|
-
len(self.col_positions) - 1,
|
6209
|
-
)
|
6210
|
-
)
|
6211
|
-
)
|
6212
|
-
)
|
6158
|
+
s = {
|
6159
|
+
r
|
6160
|
+
for item, box in self.get_selection_items(cells=False, columns=False)
|
6161
|
+
for r in range(box.coords.from_r, box.coords.upto_r)
|
6162
|
+
}
|
6163
|
+
if get_cells_as_rows:
|
6164
|
+
return s | set(tup[0] for tup in self.get_selected_cells())
|
6213
6165
|
return s
|
6214
6166
|
|
6215
6167
|
def get_selected_cols(
|
6216
6168
|
self,
|
6217
6169
|
get_cells: bool = False,
|
6218
|
-
within_range: tuple | None = None,
|
6219
6170
|
get_cells_as_cols: bool = False,
|
6220
6171
|
) -> set[int] | set[tuple[int, int]]:
|
6221
|
-
s = set()
|
6222
|
-
if within_range is not None:
|
6223
|
-
within_c1 = within_range[0]
|
6224
|
-
within_c2 = within_range[1]
|
6225
6172
|
if get_cells:
|
6226
|
-
|
6227
|
-
|
6228
|
-
|
6229
|
-
|
6230
|
-
|
6231
|
-
|
6232
|
-
|
6233
|
-
|
6234
|
-
r1, c1, r2, c2 = box.coords
|
6235
|
-
if c1 >= within_c1 or c2 <= within_c2:
|
6236
|
-
s.update(
|
6237
|
-
set(
|
6238
|
-
product(
|
6239
|
-
range(c1 if c1 > within_c1 else within_c1, c2 if c2 < within_c2 else within_c2),
|
6240
|
-
range(0, len(self.row_positions) - 1),
|
6241
|
-
)
|
6242
|
-
)
|
6243
|
-
)
|
6244
|
-
if get_cells_as_cols:
|
6245
|
-
s.update(
|
6246
|
-
self.get_selected_cells(
|
6247
|
-
within_range=(
|
6248
|
-
0,
|
6249
|
-
within_c1,
|
6250
|
-
len(self.row_positions) - 1,
|
6251
|
-
within_c2,
|
6252
|
-
)
|
6253
|
-
)
|
6254
|
-
)
|
6173
|
+
s = {
|
6174
|
+
(r, c)
|
6175
|
+
for item, box in self.get_selection_items(cells=False, rows=False)
|
6176
|
+
for r in range(0, len(self.row_positions) - 1)
|
6177
|
+
for c in range(box.coords.from_c, box.coords.upto_c)
|
6178
|
+
}
|
6179
|
+
if get_cells_as_cols:
|
6180
|
+
return s | self.get_selected_cells()
|
6255
6181
|
else:
|
6256
|
-
|
6257
|
-
|
6258
|
-
|
6259
|
-
|
6260
|
-
|
6261
|
-
|
6262
|
-
|
6263
|
-
for item in self.get_selection_items(cells=False, rows=False):
|
6264
|
-
r1, c1, r2, c2 = box.coords
|
6265
|
-
if c1 >= within_c1 or c2 <= within_c2:
|
6266
|
-
s.update(set(range(c1 if c1 > within_c1 else within_c1, c2 if c2 < within_c2 else within_c2)))
|
6267
|
-
if get_cells_as_cols:
|
6268
|
-
s.update(
|
6269
|
-
set(
|
6270
|
-
tup[0]
|
6271
|
-
for tup in self.get_selected_cells(
|
6272
|
-
within_range=(
|
6273
|
-
0,
|
6274
|
-
within_c1,
|
6275
|
-
len(self.row_positions) - 1,
|
6276
|
-
within_c2,
|
6277
|
-
)
|
6278
|
-
)
|
6279
|
-
)
|
6280
|
-
)
|
6182
|
+
s = {
|
6183
|
+
c
|
6184
|
+
for item, box in self.get_selection_items(cells=False, rows=False)
|
6185
|
+
for c in range(box.coords.from_c, box.coords.upto_c)
|
6186
|
+
}
|
6187
|
+
if get_cells_as_cols:
|
6188
|
+
return s | set(tup[1] for tup in self.get_selected_cells())
|
6281
6189
|
return s
|
6282
6190
|
|
6283
6191
|
def get_selected_cells(
|
6284
6192
|
self,
|
6285
6193
|
get_rows: bool = False,
|
6286
6194
|
get_cols: bool = False,
|
6287
|
-
within_range: bool = None,
|
6288
6195
|
) -> set[tuple[int, int]]:
|
6289
|
-
|
6290
|
-
|
6291
|
-
|
6292
|
-
|
6293
|
-
|
6294
|
-
|
6295
|
-
if within_range is None:
|
6296
|
-
for item, box in self.get_selection_items(rows=get_rows, columns=get_cols):
|
6297
|
-
r1, c1, r2, c2 = box.coords
|
6298
|
-
s.update(set(product(range(r1, r2), range(c1, c2))))
|
6299
|
-
else:
|
6300
|
-
for item in self.get_selection_items(rows=get_rows, columns=get_cols):
|
6301
|
-
r1, c1, r2, c2 = box.coords
|
6302
|
-
if r1 >= within_r1 or c1 >= within_c1 or r2 <= within_r2 or c2 <= within_c2:
|
6303
|
-
s.update(
|
6304
|
-
set(
|
6305
|
-
product(
|
6306
|
-
range(r1 if r1 > within_r1 else within_r1, r2 if r2 < within_r2 else within_r2),
|
6307
|
-
range(c1 if c1 > within_c1 else within_c1, c2 if c2 < within_c2 else within_c2),
|
6308
|
-
)
|
6309
|
-
)
|
6310
|
-
)
|
6311
|
-
return s
|
6196
|
+
return {
|
6197
|
+
(r, c)
|
6198
|
+
for item, box in self.get_selection_items(rows=get_rows, columns=get_cols)
|
6199
|
+
for r in range(box.coords.from_r, box.coords.upto_r)
|
6200
|
+
for c in range(box.coords.from_c, box.coords.upto_c)
|
6201
|
+
}
|
6312
6202
|
|
6313
6203
|
def get_all_selection_boxes(self) -> tuple[tuple[int, int, int, int]]:
|
6314
6204
|
return tuple(box.coords for item, box in self.get_selection_items())
|
@@ -6469,7 +6359,9 @@ class MainTable(tk.Canvas):
|
|
6469
6359
|
sheet=self.PAR.name,
|
6470
6360
|
key=extra_func_key,
|
6471
6361
|
value=text,
|
6472
|
-
loc=(r, c),
|
6362
|
+
loc=Loc(r, c),
|
6363
|
+
row=r,
|
6364
|
+
column=c,
|
6473
6365
|
boxes=self.get_boxes(),
|
6474
6366
|
selected=self.selected,
|
6475
6367
|
)
|
@@ -6532,12 +6424,14 @@ class MainTable(tk.Canvas):
|
|
6532
6424
|
self.text_editor.tktext.focus_set()
|
6533
6425
|
self.text_editor.window.scroll_to_bottom()
|
6534
6426
|
self.text_editor.tktext.bind("<Alt-Return>", lambda _x: self.text_editor_newline_binding(r, c))
|
6427
|
+
self.text_editor.tktext.bind("<Alt-KP_Enter>", lambda _x: self.text_editor_newline_binding(r, c))
|
6535
6428
|
if USER_OS == "darwin":
|
6536
6429
|
self.text_editor.tktext.bind("<Option-Return>", lambda _x: self.text_editor_newline_binding(r, c))
|
6537
6430
|
for key, func in self.text_editor_user_bound_keys.items():
|
6538
6431
|
self.text_editor.tktext.bind(key, func)
|
6539
6432
|
self.text_editor.tktext.bind("<Tab>", lambda _x: self.close_text_editor((r, c, "Tab")))
|
6540
6433
|
self.text_editor.tktext.bind("<Return>", lambda _x: self.close_text_editor((r, c, "Return")))
|
6434
|
+
self.text_editor.tktext.bind("<KP_Enter>", lambda _x: self.close_text_editor((r, c, "Return")))
|
6541
6435
|
if not dropdown:
|
6542
6436
|
self.text_editor.tktext.bind("<FocusOut>", lambda _x: self.close_text_editor((r, c, "FocusOut")))
|
6543
6437
|
self.text_editor.tktext.bind("<Escape>", lambda _x: self.close_text_editor((r, c, "Escape")))
|
@@ -6627,8 +6521,8 @@ class MainTable(tk.Canvas):
|
|
6627
6521
|
|
6628
6522
|
def hide_text_editor(self, reason: None | str = None) -> None:
|
6629
6523
|
if self.text_editor.open:
|
6630
|
-
for
|
6631
|
-
self.text_editor.tktext.unbind(
|
6524
|
+
for binding in text_editor_to_unbind:
|
6525
|
+
self.text_editor.tktext.unbind(binding)
|
6632
6526
|
self.itemconfig(self.text_editor.canvas_id, state="hidden")
|
6633
6527
|
self.text_editor.open = False
|
6634
6528
|
if reason == "Escape":
|
@@ -6660,7 +6554,9 @@ class MainTable(tk.Canvas):
|
|
6660
6554
|
cells_table={(datarn, datacn): text_editor_value},
|
6661
6555
|
key=editor_info[2],
|
6662
6556
|
value=text_editor_value,
|
6663
|
-
loc=(r, c),
|
6557
|
+
loc=Loc(r, c),
|
6558
|
+
row=r,
|
6559
|
+
column=c,
|
6664
6560
|
boxes=self.get_boxes(),
|
6665
6561
|
selected=self.selected,
|
6666
6562
|
)
|
@@ -6911,7 +6807,9 @@ class MainTable(tk.Canvas):
|
|
6911
6807
|
name="table_dropdown_modified",
|
6912
6808
|
sheet=self.PAR.name,
|
6913
6809
|
value=self.text_editor.get(),
|
6914
|
-
loc=(r, c),
|
6810
|
+
loc=Loc(r, c),
|
6811
|
+
row=r,
|
6812
|
+
column=c,
|
6915
6813
|
boxes=self.get_boxes(),
|
6916
6814
|
selected=self.selected,
|
6917
6815
|
)
|
@@ -6954,7 +6852,9 @@ class MainTable(tk.Canvas):
|
|
6954
6852
|
cells_table={(datarn, datacn): pre_edit_value},
|
6955
6853
|
key="??",
|
6956
6854
|
value=selection,
|
6957
|
-
loc=(r, c),
|
6855
|
+
loc=Loc(r, c),
|
6856
|
+
row=r,
|
6857
|
+
column=c,
|
6958
6858
|
boxes=self.get_boxes(),
|
6959
6859
|
selected=self.selected,
|
6960
6860
|
)
|
@@ -7042,7 +6942,9 @@ class MainTable(tk.Canvas):
|
|
7042
6942
|
cells_table={(datarn, datacn): pre_edit_value},
|
7043
6943
|
key="??",
|
7044
6944
|
value=value,
|
7045
|
-
loc=(r, c),
|
6945
|
+
loc=Loc(r, c),
|
6946
|
+
row=r,
|
6947
|
+
column=c,
|
7046
6948
|
boxes=self.get_boxes(),
|
7047
6949
|
selected=self.selected,
|
7048
6950
|
)
|
@@ -7161,7 +7063,7 @@ class MainTable(tk.Canvas):
|
|
7161
7063
|
|
7162
7064
|
def fix_data_len(self, datarn: int, datacn: int | None = None) -> int:
|
7163
7065
|
ncols = self.total_data_cols() if datacn is None else datacn + 1
|
7164
|
-
self.data.extend(
|
7066
|
+
self.data.extend(self.get_empty_row_seq(rn, end=ncols, start=0) for rn in range(len(self.data), datarn + 1))
|
7165
7067
|
return len(self.data)
|
7166
7068
|
|
7167
7069
|
def reapply_formatting(self) -> None:
|