tksheet 7.4.5__py3-none-any.whl → 7.4.6__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 +28 -28
- tksheet/constants.py +4 -3
- tksheet/find_window.py +8 -8
- tksheet/formatters.py +39 -39
- tksheet/functions.py +53 -57
- tksheet/main_table.py +153 -122
- tksheet/other_classes.py +11 -11
- tksheet/row_index.py +27 -27
- tksheet/sheet.py +99 -110
- tksheet/sorting.py +19 -18
- tksheet/text_editor.py +9 -9
- tksheet/tksheet_types.py +187 -0
- tksheet/top_left_rectangle.py +13 -12
- {tksheet-7.4.5.dist-info → tksheet-7.4.6.dist-info}/METADATA +1 -1
- tksheet-7.4.6.dist-info/RECORD +22 -0
- tksheet-7.4.5.dist-info/RECORD +0 -22
- {tksheet-7.4.5.dist-info → tksheet-7.4.6.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.4.5.dist-info → tksheet-7.4.6.dist-info}/WHEEL +0 -0
- {tksheet-7.4.5.dist-info → tksheet-7.4.6.dist-info}/top_level.txt +0 -0
tksheet/other_classes.py
CHANGED
@@ -5,7 +5,7 @@ import tkinter as tk
|
|
5
5
|
from collections import namedtuple
|
6
6
|
from collections.abc import Callable, Hashable, Iterator
|
7
7
|
from functools import partial
|
8
|
-
from typing import Literal
|
8
|
+
from typing import Any, Literal
|
9
9
|
|
10
10
|
pickle_obj = partial(pickle.dumps, protocol=pickle.HIGHEST_PROTOCOL)
|
11
11
|
|
@@ -131,7 +131,7 @@ class DotDict(dict):
|
|
131
131
|
def __setstate__(self, state: DotDict) -> None:
|
132
132
|
self.update(state)
|
133
133
|
|
134
|
-
def __setitem__(self, key: Hashable, item:
|
134
|
+
def __setitem__(self, key: Hashable, item: Any) -> None:
|
135
135
|
if type(item) is dict: # noqa: E721
|
136
136
|
super().__setitem__(key, DotDict(item))
|
137
137
|
else:
|
@@ -165,13 +165,13 @@ class Span(dict):
|
|
165
165
|
def __setstate__(self, state: Span) -> None:
|
166
166
|
self.update(state)
|
167
167
|
|
168
|
-
def __getitem__(self, key: Hashable) ->
|
168
|
+
def __getitem__(self, key: Hashable) -> Any:
|
169
169
|
if key == "data" or key == "value":
|
170
170
|
return self["widget"].get_data(self)
|
171
171
|
else:
|
172
172
|
return super().__getitem__(key)
|
173
173
|
|
174
|
-
def __setitem__(self, key: Hashable, item:
|
174
|
+
def __setitem__(self, key: Hashable, item: Any) -> None:
|
175
175
|
if key == "data" or key == "value":
|
176
176
|
self["widget"].set_data(self, data=item)
|
177
177
|
elif key == "bg":
|
@@ -188,7 +188,7 @@ class Span(dict):
|
|
188
188
|
def format(
|
189
189
|
self,
|
190
190
|
formatter_options: dict | None = None,
|
191
|
-
formatter_class:
|
191
|
+
formatter_class: Any = None,
|
192
192
|
redraw: bool = True,
|
193
193
|
**kwargs,
|
194
194
|
) -> Span:
|
@@ -232,10 +232,10 @@ class Span(dict):
|
|
232
232
|
|
233
233
|
def dropdown(
|
234
234
|
self,
|
235
|
-
values: list[
|
235
|
+
values: list[Any] | None = None,
|
236
236
|
edit_data: bool = True,
|
237
|
-
set_values: dict[tuple[int, int],
|
238
|
-
set_value:
|
237
|
+
set_values: dict[tuple[int, int], Any] | None = None,
|
238
|
+
set_value: Any = None,
|
239
239
|
state: str = "normal",
|
240
240
|
redraw: bool = True,
|
241
241
|
selection_function: Callable | None = None,
|
@@ -327,7 +327,7 @@ class Span(dict):
|
|
327
327
|
convert: Callable | None = None,
|
328
328
|
undo: bool | None = None,
|
329
329
|
emit_event: bool | None = None,
|
330
|
-
widget:
|
330
|
+
widget: Any = None,
|
331
331
|
expand: str | None = None,
|
332
332
|
formatter_options: dict | None = None,
|
333
333
|
**kwargs,
|
@@ -504,7 +504,7 @@ class EditorStorageBase(StorageBase):
|
|
504
504
|
self.highlight_from(index, line, column)
|
505
505
|
|
506
506
|
@property
|
507
|
-
def tktext(self) ->
|
507
|
+
def tktext(self) -> Any:
|
508
508
|
if self.window:
|
509
509
|
return self.window.tktext
|
510
510
|
return self.window
|
@@ -537,7 +537,7 @@ class ProgressBar:
|
|
537
537
|
def __len__(self):
|
538
538
|
return 2
|
539
539
|
|
540
|
-
def __getitem__(self, key: Hashable) ->
|
540
|
+
def __getitem__(self, key: Hashable) -> Any:
|
541
541
|
if key == 0:
|
542
542
|
return self.bg
|
543
543
|
elif key == 1:
|
tksheet/row_index.py
CHANGED
@@ -7,7 +7,7 @@ from functools import partial
|
|
7
7
|
from itertools import chain, cycle, islice, repeat
|
8
8
|
from math import ceil, floor
|
9
9
|
from operator import itemgetter
|
10
|
-
from typing import Literal
|
10
|
+
from typing import Any, Literal
|
11
11
|
|
12
12
|
from .colors import color_map
|
13
13
|
from .constants import (
|
@@ -160,7 +160,7 @@ class RowIndex(tk.Canvas):
|
|
160
160
|
self.MT.recreate_all_selection_boxes()
|
161
161
|
self.current_width = new_width
|
162
162
|
|
163
|
-
def rc(self, event:
|
163
|
+
def rc(self, event: Any) -> None:
|
164
164
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
165
165
|
self.focus_set()
|
166
166
|
popup_menu = None
|
@@ -187,7 +187,7 @@ class RowIndex(tk.Canvas):
|
|
187
187
|
self.popup_menu_loc = r
|
188
188
|
popup_menu.tk_popup(event.x_root, event.y_root)
|
189
189
|
|
190
|
-
def ctrl_b1_press(self, event:
|
190
|
+
def ctrl_b1_press(self, event: Any) -> None:
|
191
191
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
192
192
|
if (
|
193
193
|
(self.drag_and_drop_enabled or self.row_selection_enabled)
|
@@ -210,7 +210,7 @@ class RowIndex(tk.Canvas):
|
|
210
210
|
elif not self.MT.ctrl_select_enabled:
|
211
211
|
self.b1_press(event)
|
212
212
|
|
213
|
-
def ctrl_shift_b1_press(self, event:
|
213
|
+
def ctrl_shift_b1_press(self, event: Any) -> None:
|
214
214
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
215
215
|
y = event.y
|
216
216
|
r = self.MT.identify_row(y=y)
|
@@ -246,7 +246,7 @@ class RowIndex(tk.Canvas):
|
|
246
246
|
elif not self.MT.ctrl_select_enabled:
|
247
247
|
self.shift_b1_press(event)
|
248
248
|
|
249
|
-
def shift_b1_press(self, event:
|
249
|
+
def shift_b1_press(self, event: Any) -> None:
|
250
250
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
251
251
|
r = self.MT.identify_row(y=event.y)
|
252
252
|
if (
|
@@ -317,7 +317,7 @@ class RowIndex(tk.Canvas):
|
|
317
317
|
if x >= x1 and y >= y1 and x <= x2 and y <= y2:
|
318
318
|
return r
|
319
319
|
|
320
|
-
def mouse_motion(self, event:
|
320
|
+
def mouse_motion(self, event: Any) -> None:
|
321
321
|
if not self.currently_resizing_height and not self.currently_resizing_width:
|
322
322
|
x = self.canvasx(event.x)
|
323
323
|
y = self.canvasy(event.y)
|
@@ -367,7 +367,7 @@ class RowIndex(tk.Canvas):
|
|
367
367
|
self.MT.reset_mouse_motion_creations()
|
368
368
|
try_binding(self.extra_motion_func, event)
|
369
369
|
|
370
|
-
def double_b1(self, event:
|
370
|
+
def double_b1(self, event: Any):
|
371
371
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
372
372
|
self.focus_set()
|
373
373
|
if (
|
@@ -413,7 +413,7 @@ class RowIndex(tk.Canvas):
|
|
413
413
|
self.mouse_motion(event)
|
414
414
|
try_binding(self.extra_double_b1_func, event)
|
415
415
|
|
416
|
-
def b1_press(self, event:
|
416
|
+
def b1_press(self, event: Any):
|
417
417
|
self.MT.unbind("<MouseWheel>")
|
418
418
|
self.focus_set()
|
419
419
|
self.closed_dropdown = self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
@@ -482,7 +482,7 @@ class RowIndex(tk.Canvas):
|
|
482
482
|
self.toggle_select_row(r, redraw=True)
|
483
483
|
try_binding(self.extra_b1_press_func, event)
|
484
484
|
|
485
|
-
def b1_motion(self, event:
|
485
|
+
def b1_motion(self, event: Any):
|
486
486
|
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
487
487
|
if self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
|
488
488
|
y = self.canvasy(event.y)
|
@@ -581,7 +581,7 @@ class RowIndex(tk.Canvas):
|
|
581
581
|
elif end_row < start_row:
|
582
582
|
return end_row, 0, start_row + 1, len(self.MT.col_positions) - 1, "rows"
|
583
583
|
|
584
|
-
def ctrl_b1_motion(self, event:
|
584
|
+
def ctrl_b1_motion(self, event: Any) -> None:
|
585
585
|
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
586
586
|
if (
|
587
587
|
self.drag_and_drop_enabled
|
@@ -635,7 +635,7 @@ class RowIndex(tk.Canvas):
|
|
635
635
|
elif not self.MT.ctrl_select_enabled:
|
636
636
|
self.b1_motion(event)
|
637
637
|
|
638
|
-
def drag_and_drop_motion(self, event:
|
638
|
+
def drag_and_drop_motion(self, event: Any) -> float:
|
639
639
|
y = event.y
|
640
640
|
hend = self.winfo_height()
|
641
641
|
ycheck = self.yview()
|
@@ -703,7 +703,7 @@ class RowIndex(tk.Canvas):
|
|
703
703
|
if ctrl_lines:
|
704
704
|
self.MT.delete_ctrl_outlines()
|
705
705
|
|
706
|
-
def scroll_if_event_offscreen(self, event:
|
706
|
+
def scroll_if_event_offscreen(self, event: Any) -> bool:
|
707
707
|
ycheck = self.yview()
|
708
708
|
need_redraw = False
|
709
709
|
if event.y > self.winfo_height() and len(ycheck) > 1 and ycheck[1] < 1:
|
@@ -733,14 +733,14 @@ class RowIndex(tk.Canvas):
|
|
733
733
|
if len(ycheck) > 1 and ycheck[1] > 1:
|
734
734
|
self.MT.set_yviews("moveto", 1)
|
735
735
|
|
736
|
-
def event_over_dropdown(self, r: int, datarn: int, event:
|
736
|
+
def event_over_dropdown(self, r: int, datarn: int, event: Any, canvasy: float) -> bool:
|
737
737
|
return (
|
738
738
|
canvasy < self.MT.row_positions[r] + self.MT.index_txt_height
|
739
739
|
and self.get_cell_kwargs(datarn, key="dropdown")
|
740
740
|
and event.x > self.current_width - self.MT.index_txt_height - 4
|
741
741
|
)
|
742
742
|
|
743
|
-
def event_over_checkbox(self, r: int, datarn: int, event:
|
743
|
+
def event_over_checkbox(self, r: int, datarn: int, event: Any, canvasy: float) -> bool:
|
744
744
|
return (
|
745
745
|
canvasy < self.MT.row_positions[r] + self.MT.index_txt_height
|
746
746
|
and self.get_cell_kwargs(datarn, key="checkbox")
|
@@ -777,7 +777,7 @@ class RowIndex(tk.Canvas):
|
|
777
777
|
)
|
778
778
|
)
|
779
779
|
|
780
|
-
def b1_release(self, event:
|
780
|
+
def b1_release(self, event: Any) -> None:
|
781
781
|
to_hide = self.being_drawn_item
|
782
782
|
if self.being_drawn_item is not None and (to_sel := self.MT.coords_and_type(self.being_drawn_item)):
|
783
783
|
r_to_sel, c_to_sel = self.MT.selected.row, self.MT.selected.column
|
@@ -1912,7 +1912,7 @@ class RowIndex(tk.Canvas):
|
|
1912
1912
|
d[box.type_ if box.type_ != "columns" else "cells"].add(r)
|
1913
1913
|
return d
|
1914
1914
|
|
1915
|
-
def open_cell(self, event:
|
1915
|
+
def open_cell(self, event: Any = None, ignore_existing_editor: bool = False) -> None:
|
1916
1916
|
if not self.MT.anything_selected() or (not ignore_existing_editor and self.text_editor.open):
|
1917
1917
|
return
|
1918
1918
|
if not self.MT.selected:
|
@@ -1942,7 +1942,7 @@ class RowIndex(tk.Canvas):
|
|
1942
1942
|
# r is displayed row
|
1943
1943
|
def open_text_editor(
|
1944
1944
|
self,
|
1945
|
-
event:
|
1945
|
+
event: Any = None,
|
1946
1946
|
r: int = 0,
|
1947
1947
|
text: None | str = None,
|
1948
1948
|
state: str = "normal",
|
@@ -2035,7 +2035,7 @@ class RowIndex(tk.Canvas):
|
|
2035
2035
|
self.text_editor.tktext.bind(key, func)
|
2036
2036
|
return True
|
2037
2037
|
|
2038
|
-
def text_editor_newline_binding(self, event:
|
2038
|
+
def text_editor_newline_binding(self, event: Any = None, check_lines: bool = True) -> None:
|
2039
2039
|
if not self.height_resizing_enabled:
|
2040
2040
|
return
|
2041
2041
|
curr_height = self.text_editor.window.winfo_height()
|
@@ -2232,7 +2232,7 @@ class RowIndex(tk.Canvas):
|
|
2232
2232
|
self.text_editor.autocomplete(self.dropdown.window.search_and_see(event_data))
|
2233
2233
|
return "break"
|
2234
2234
|
|
2235
|
-
def open_dropdown_window(self, r: int, event:
|
2235
|
+
def open_dropdown_window(self, r: int, event: Any = None) -> None:
|
2236
2236
|
self.hide_text_editor()
|
2237
2237
|
kwargs = self.get_cell_kwargs(self.MT.datarn(r), key="dropdown")
|
2238
2238
|
if kwargs["state"] == "disabled":
|
@@ -2310,7 +2310,7 @@ class RowIndex(tk.Canvas):
|
|
2310
2310
|
def close_dropdown_window(
|
2311
2311
|
self,
|
2312
2312
|
r: int | None = None,
|
2313
|
-
selection:
|
2313
|
+
selection: Any = None,
|
2314
2314
|
redraw: bool = True,
|
2315
2315
|
) -> None:
|
2316
2316
|
if r is not None and selection is not None:
|
@@ -2417,7 +2417,7 @@ class RowIndex(tk.Canvas):
|
|
2417
2417
|
self.MT.sheet_modified(event_data)
|
2418
2418
|
return edited
|
2419
2419
|
|
2420
|
-
def set_cell_data(self, datarn: int | None = None, value:
|
2420
|
+
def set_cell_data(self, datarn: int | None = None, value: Any = "") -> None:
|
2421
2421
|
if isinstance(self.MT._row_index, int):
|
2422
2422
|
self.MT.set_cell_data(datarn=datarn, datacn=self.MT._row_index, value=value)
|
2423
2423
|
else:
|
@@ -2429,7 +2429,7 @@ class RowIndex(tk.Canvas):
|
|
2429
2429
|
else:
|
2430
2430
|
self.MT._row_index[datarn] = value
|
2431
2431
|
|
2432
|
-
def input_valid_for_cell(self, datarn: int, value:
|
2432
|
+
def input_valid_for_cell(self, datarn: int, value: Any, check_readonly: bool = True) -> bool:
|
2433
2433
|
kwargs = self.get_cell_kwargs(datarn, key=None)
|
2434
2434
|
if check_readonly and "readonly" in kwargs:
|
2435
2435
|
return False
|
@@ -2443,7 +2443,7 @@ class RowIndex(tk.Canvas):
|
|
2443
2443
|
and value not in kwargs["values"]
|
2444
2444
|
)
|
2445
2445
|
|
2446
|
-
def cell_equal_to(self, datarn: int, value:
|
2446
|
+
def cell_equal_to(self, datarn: int, value: Any) -> bool:
|
2447
2447
|
self.fix_index(datarn)
|
2448
2448
|
if isinstance(self.MT._row_index, list):
|
2449
2449
|
return self.MT._row_index[datarn] == value
|
@@ -2456,7 +2456,7 @@ class RowIndex(tk.Canvas):
|
|
2456
2456
|
get_displayed: bool = False,
|
2457
2457
|
none_to_empty_str: bool = False,
|
2458
2458
|
redirect_int: bool = False,
|
2459
|
-
) ->
|
2459
|
+
) -> Any:
|
2460
2460
|
if get_displayed:
|
2461
2461
|
return self.get_valid_cell_data_as_str(datarn, fix=False)
|
2462
2462
|
if redirect_int and isinstance(self.MT._row_index, int): # internal use
|
@@ -2499,7 +2499,7 @@ class RowIndex(tk.Canvas):
|
|
2499
2499
|
value = get_n2a(datarn, self.ops.default_row_index)
|
2500
2500
|
return value
|
2501
2501
|
|
2502
|
-
def get_value_for_empty_cell(self, datarn: int, r_ops: bool = True) ->
|
2502
|
+
def get_value_for_empty_cell(self, datarn: int, r_ops: bool = True) -> Any:
|
2503
2503
|
if self.ops.treeview:
|
2504
2504
|
iid = self.new_iid()
|
2505
2505
|
return Node(text=iid, iid=iid, parent=self.get_row_parent(datarn))
|
@@ -2511,7 +2511,7 @@ class RowIndex(tk.Canvas):
|
|
2511
2511
|
else:
|
2512
2512
|
return ""
|
2513
2513
|
|
2514
|
-
def get_empty_index_seq(self, end: int, start: int = 0, r_ops: bool = True) -> list[
|
2514
|
+
def get_empty_index_seq(self, end: int, start: int = 0, r_ops: bool = True) -> list[Any]:
|
2515
2515
|
return [self.get_value_for_empty_cell(datarn, r_ops=r_ops) for datarn in range(start, end)]
|
2516
2516
|
|
2517
2517
|
def fix_index(self, datarn: int | None = None) -> None:
|
@@ -2998,7 +2998,7 @@ class RowIndex(tk.Canvas):
|
|
2998
2998
|
|
2999
2999
|
def tree_build(
|
3000
3000
|
self,
|
3001
|
-
data: list[list[
|
3001
|
+
data: list[list[Any]],
|
3002
3002
|
iid_column: int,
|
3003
3003
|
parent_column: int,
|
3004
3004
|
text_column: None | int | list[str] = None,
|